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 //Don't forget to call glitchvoltages().
21 TACTL=0; //Clear dividers.
22 TACTL|=TACLR; //Clear TimerA Config
24 TASSEL_SMCLK | //SMCLK source,
25 MC_1 | //Count up to CCR0
26 TAIE; //Enable Interrupt
27 CCTL0 = CCIE; // CCR0 interrupt enabled
30 //Enable general interrupts, just in case.
38 //Set GSEL high to disable glitching.
46 WDTCTL = WDTPW + WDTHOLD; // Stop WDT
47 TACTL = TASSEL1 + TACLR; // SMCLK, clear TAR
48 CCTL0 = CCIE; // CCR0 interrupt enabled
50 TACTL |= MC1; // Start Timer_A in continuous mode
51 //TACTL |= MC0; // Stop Timer_A;
52 _EINT(); // Enable interrupts
56 // Timer A0 interrupt service routine
57 interrupt(TIMERA0_VECTOR) Timer_A (void)
61 TACTL |= MC0; // Stop Timer_A;
70 //! Glitch an application.
71 void glitchapp(u8 app){
72 debugstr("That app is not yet supported.");
76 //! Set glitching voltages.
77 void glitchvoltages(u16 gnd, u16 vcc){
79 //debugstr("Set glitching voltages.");
82 ADC12CTL0 = REF2_5V + REFON; // Internal 2.5V ref on
83 // Delay here for reference to settle.
84 for(i=0;i!=0xFFFF;i++) asm("nop");
85 DAC12_0CTL = DAC12IR + DAC12AMP_5 + DAC12ENC; // Int ref gain 1
86 DAC12_1CTL = DAC12IR + DAC12AMP_5 + DAC12ENC; // Int ref gain 1
87 // 1.0V 0x0666, 2.5V 0x0FFF
88 DAC12_0DAT = vcc; //high;
89 DAC12_1DAT = gnd; //low;
92 //! Set glitching rate.
93 void glitchrate(u16 rate){
97 //! Handles a monitor command.
98 void glitchhandle(unsigned char app,
103 glitchvoltages(cmddataword[0],
108 glitchrate(cmddataword[0]);
112 //FIXME parameters don't work yet.
114 handle(cmddata[0],cmddata[1],0);
117 _DINT();//disable interrupts
118 TACTL=0; //clear dividers
119 TACTL|=TACLR; //clear config
120 TACTL|=TASSEL_SMCLK| //smclk source
121 MC_2; //continuout mode.
123 //perform the function
124 silent++;//Don't want the function to return anything.
125 handle(cmddata[0],cmddata[1],0);
127 cmddataword[0]=TAR; //Return counter.
131 glitchvoltages(0xFFF,0);//Inverted VCC and GND.
135 P5OUT&=~BIT7;//Glitch
136 //asm("nop");//asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
137 asm("nop"); //Not necessary.
139 asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
140 asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
147 debugstr("Unknown glitching verb.");