2 \author Travis Goodspeed
3 \brief Glitching Support for GoodFET20
5 See the TI example MSP430x261x_dac12_01.c for usage of the DAC.
6 This module sends odd and insufficient voltages on P6.6/DAC0
7 in order to bypass security restrictions of target devices.
15 //! Call this before the function to be glitched.
18 WDTCTL = WDTPW + WDTHOLD; // Stop WDT
29 //Set GSEL high to disable glitching.
31 //Normal voltage, use resistors instead of output.
32 //P5DIR=0x80; //ONLY glitch pin is output.
33 P5DIR|=0x80; //glitch pin is output.
34 P5OUT|=0x80; //It MUST begin high.
35 //P5REN|=0x7F; //Resistors pull high and low weakly.
40 WDTCTL = WDTPW + WDTHOLD; // Stop WDT
41 TACTL = TASSEL1 + TACLR; // SMCLK, clear TAR
42 CCTL0 = CCIE; // CCR0 interrupt enabled
43 CCR0 = glitchcount+0x10; // Compare Value
44 TACTL |= MC_2; // continuous mode.
48 // Timer A0 interrupt service routine
49 interrupt(TIMERA0_VECTOR) Timer_A (void){
50 //This oughtn't be necessary, but glitches repeat without it.
51 TACTL=0; //disable counter.
55 //asm("nop"); //delay deepens glitch.
58 //This oughtn't be necessary, but glitches repeat without it.
59 TACTL=0; //disable counter.
61 //P5OUT^=BIT7;//Normal
68 //! Glitch an application.
69 void glitchapp(u8 app){
70 debugstr("That app is not yet supported.");
74 //! Set glitching voltages.
75 void glitchvoltages(u16 gnd, u16 vcc){
77 //debugstr("Set glitching voltages: GND and VCC");
81 /** N.B., because this is confusing as hell. As per Page 86 of
82 SLAS541F, P6SEL is not what controls the use of the DAC0/DAC1
83 functions on P6.6 and P6.5. Instead, CAPD or DAC12AMP>0 sets
88 ADC12CTL0 = REF2_5V + REFON; // Internal 2.5V ref on
89 // Delay here for reference to settle.
90 for(i=0;i!=0xFFFF;i++) asm("nop");
91 DAC12_0CTL = DAC12IR + DAC12AMP_5 + DAC12ENC; // Int ref gain 1
92 DAC12_1CTL = DAC12IR + DAC12AMP_5 + DAC12ENC; // Int ref gain 1
93 // 1.0V 0x0666, 2.5V 0x0FFF
94 DAC12_0DAT = vcc; //high;
95 DAC12_1DAT = gnd; //low;
98 //! Set glitching rate.
99 void glitchrate(u16 rate){
103 //! Handles a monitor command.
104 void glitchhandle(unsigned char app,
109 glitchvoltages(cmddataword[0],
114 glitchrate(cmddataword[0]);
118 //FIXME parameters don't work yet.
120 TAR=0; //Reset clock.
121 handle(cmddata[0],cmddata[1],0);
122 TACTL |= MC0;// Stop Timer_A;
125 _DINT();//disable interrupts
126 TACTL=0; //clear dividers
127 TACTL|=TACLR; //clear config
128 TACTL|=TASSEL_SMCLK| //smclk source
129 MC_2; //continuous mode.
131 //perform the function
132 silent++;//Don't want the function to return anything.
134 handle(cmddata[0],cmddata[1],0);
135 cmddataword[0]=TAR; //Return counter.
140 //Testing mode, for looking at the glitch waveform.
141 glitchvoltages(0,0xFFF);//Minimum glitch, for noise test.
142 //glitchvoltages(0,0);//Drop VCC
143 //glitchvoltages(0xFFF,0xFFF);//Raise Ground
147 P5OUT&=~BIT7;//Glitch
148 //asm("nop"); //Not Necessary
150 asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
151 asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
158 debugstr("Unknown glitching verb.");