From ccbb5f9f7ae6fee33ba360030ecdaa76e7967024 Mon Sep 17 00:00:00 2001 From: travisutk Date: Tue, 19 Jan 2010 01:32:56 +0000 Subject: [PATCH] Cleaning up glitching. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@267 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- firmware/apps/avr/avr.c | 6 ++--- firmware/apps/glitch/glitch.c | 47 ++++++++++++++++++++++++++++++++--- firmware/goodfet.c | 3 +-- firmware/include/glitch.h | 4 ++- 4 files changed, 50 insertions(+), 10 deletions(-) diff --git a/firmware/apps/avr/avr.c b/firmware/apps/avr/avr.c index a127ea2..577d878 100644 --- a/firmware/apps/avr/avr.c +++ b/firmware/apps/avr/avr.c @@ -16,8 +16,6 @@ //! Setup the AVR pins. void avrsetup(){ spisetup(); - - glitchsetup(); } //! Initialized an attached AVR. @@ -31,9 +29,9 @@ void avrconnect(){ SETSS; CLRCLK; - delay(500); + delay(10); CLRSS; - delay(500); + delay(10); //Enable programming avr_prgen(); diff --git a/firmware/apps/glitch/glitch.c b/firmware/apps/glitch/glitch.c index 7de962c..9077245 100644 --- a/firmware/apps/glitch/glitch.c +++ b/firmware/apps/glitch/glitch.c @@ -11,7 +11,29 @@ #include "command.h" #include "glitch.h" -//! Disable glitch state at init. + +//! Call this before the function to be glitched. +void glitchprime(){ +#ifdef DAC12IR + //Set to high voltage. + DAC12_0DAT = glitchH; + + //Reconfigure TACTL. + TACTL=0; //Clear dividers. + TACTL|=TACLR; //Clear TimerA Config + TACTL|= + TASSEL_SMCLK | //SMCLK source, + MC_1; //Count up to CCR0 + //TAIE; //Enable Interrupt + CCTL0 = CCIE; // CCR0 interrupt enabled + CCR0 = glitchcount; + + //Enable general interrupts, just in case. + _EINT(); +#endif +} + +//! Setup glitching. void glitchsetup(){ #ifdef DAC12IR //Set GSEL high to disable glitching. @@ -42,6 +64,21 @@ void glitchsetupdac(){ interrupt(TIMERA0_VECTOR) Timer_A (void) { #ifdef DAC12IR + debugstr("Glitching."); + DAC12_0DAT = 0;//glitchL; + asm("nop");/* + asm("nop"); + asm("nop"); + asm("nop"); + asm("nop"); + asm("nop"); + asm("nop"); + asm("nop"); + asm("nop"); + asm("nop");*/ + //DAC12_0DAT = glitchH; + //DAC12_0DAT = glitchL; + /* switch(glitchstate){ case 0: P1OUT|=1; @@ -58,7 +95,7 @@ interrupt(TIMERA0_VECTOR) Timer_A (void) //Do nothing. break; } - CCR0 += glitchcount; // Add Offset to CCR0 + */ #endif } @@ -111,10 +148,14 @@ void glitchhandle(unsigned char app, glitchrate(cmddataword[0]); txdata(app,verb,0); break; + case GLITCHVERB: + //FIXME parameters don't work yet. + glitchprime(); + handle(cmddata[0],cmddata[1],0); + break; case START: case STOP: case GLITCHAPP: - case GLITCHVERB: default: debugstr("Unknown glitching verb."); txdata(app,NOK,0); diff --git a/firmware/goodfet.c b/firmware/goodfet.c index ee97ebb..aa3a3f5 100644 --- a/firmware/goodfet.c +++ b/firmware/goodfet.c @@ -84,8 +84,7 @@ int main(void) unsigned long len; init(); - glitchsetup(); - + txstring(MONITOR,OK,"http://goodfet.sf.net/"); diff --git a/firmware/include/glitch.h b/firmware/include/glitch.h index 6f30d6d..7576c7e 100644 --- a/firmware/include/glitch.h +++ b/firmware/include/glitch.h @@ -13,10 +13,12 @@ #define GLITCHVOLTAGES 0x90 #define GLITCHRATE 0x91 -//! Disable glitch state at init. +//! Setup glitching. void glitchsetup(); //! Setup analog chain for glitching. void glitchsetupdac(); +//! Call this before the function to be glitched. +void glitchprime(); extern u16 glitchH, glitchL, glitchstate, glitchcount; -- 2.20.1