title: The Cleanest Reset for an ARM Processor
body: <p>Lately, I've been cleaning up some some C code that runs on an ARM7 controller. In some situations (upgrade, fatal error, etc...) the program will perform a reset. Presently it just jumps to 0 and assumes that the start-up code will reinitialize everything correctly. It got me to thinking about what would be the best procedure a la "Leave No Trace" for an ARM reset. Here is my first crack at it: </p>
  
  <pre><code>void Reset(void)
  {
     /* Disable interrupts */
     __disable_interrupts();
  
  /* Reset peripherals, externals and processor */
  AT91C_BASE_RSTC-&gt;RSTC_RCR = AT91C_RSTC_KEY | AT91C_RSTC_PERRST | AT91C_RSTC_EXTRST| AT91C_RSTC_PROCRST;
  
  while(AT91C_BASE_RSTC-&gt;RSTC_RSR &amp; AT91C_RSTC_SRCMP);
  
  /* Jump to the reset vector */
  (*(void(*)())0)();
  }
  </code></pre>
  
  <p>This code assumes the IAR ARM compiler and the At91Lib. Anything I haven't considered?</p>