Cleaning up glitching.
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Tue, 19 Jan 2010 01:32:56 +0000 (01:32 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Tue, 19 Jan 2010 01:32:56 +0000 (01:32 +0000)
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@267 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

firmware/apps/avr/avr.c
firmware/apps/glitch/glitch.c
firmware/goodfet.c
firmware/include/glitch.h

index a127ea2..577d878 100644 (file)
@@ -16,8 +16,6 @@
 //! Setup the AVR pins.
 void avrsetup(){
   spisetup();
 //! Setup the AVR pins.
 void avrsetup(){
   spisetup();
-  
-  glitchsetup();
 }
 
 //! Initialized an attached AVR.
 }
 
 //! Initialized an attached AVR.
@@ -31,9 +29,9 @@ void avrconnect(){
 
   SETSS;
   CLRCLK;
 
   SETSS;
   CLRCLK;
-  delay(500);
+  delay(10);
   CLRSS;
   CLRSS;
-  delay(500);
+  delay(10);
   
   //Enable programming
   avr_prgen();
   
   //Enable programming
   avr_prgen();
index 7de962c..9077245 100644 (file)
 #include "command.h"
 #include "glitch.h"
 
 #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.
 void glitchsetup(){
 #ifdef DAC12IR
   //Set GSEL high to disable glitching.
@@ -42,6 +64,21 @@ void glitchsetupdac(){
 interrupt(TIMERA0_VECTOR) Timer_A (void)
 {
 #ifdef DAC12IR
 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;
   switch(glitchstate){
   case 0:
     P1OUT|=1;
@@ -58,7 +95,7 @@ interrupt(TIMERA0_VECTOR) Timer_A (void)
     //Do nothing.
     break;
   }
     //Do nothing.
     break;
   }
-  CCR0 += glitchcount;                        // Add Offset to CCR0
+  */
 #endif
 }
 
 #endif
 }
 
@@ -111,10 +148,14 @@ void glitchhandle(unsigned char app,
     glitchrate(cmddataword[0]);
     txdata(app,verb,0);
     break;
     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 START:
   case STOP:
   case GLITCHAPP:
-  case GLITCHVERB:
   default:
     debugstr("Unknown glitching verb.");
     txdata(app,NOK,0);
   default:
     debugstr("Unknown glitching verb.");
     txdata(app,NOK,0);
index ee97ebb..aa3a3f5 100644 (file)
@@ -84,8 +84,7 @@ int main(void)
   unsigned long len;\r
   \r
   init();\r
   unsigned long len;\r
   \r
   init();\r
-  glitchsetup();\r
-  \r
+\r
   txstring(MONITOR,OK,"http://goodfet.sf.net/");\r
   \r
   \r
   txstring(MONITOR,OK,"http://goodfet.sf.net/");\r
   \r
   \r
index 6f30d6d..7576c7e 100644 (file)
 #define GLITCHVOLTAGES 0x90
 #define GLITCHRATE     0x91
 
 #define GLITCHVOLTAGES 0x90
 #define GLITCHRATE     0x91
 
-//! Disable glitch state at init.
+//! Setup glitching.
 void glitchsetup();
 //! Setup analog chain for glitching.
 void glitchsetupdac();
 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;
 
 
 extern u16 glitchH, glitchL, glitchstate, glitchcount;