[En-Nut-Discussion] ASM Branch

Janusz U. nopsoft at poczta.onet.pl
Fri Nov 17 17:39:32 CET 2006


my soft-reset solution for AT91SAM7S256:

#define WITH_SAMBA   0
#if WITH_SAMBA
 #define RESET_ADDR  "0x00108000"
#else
 #define RESET_ADDR  "0x00100000"
#endif

void kReset() {
 kprintf("Reset demand!\n");
 vPortEnterCritical();  // halt the OS
#if SOFTWARE_RESET
 AT91F_WDTSetMode(AT91C_BASE_WDTC, AT91C_WDTC_WDDIS); // disable watchdog
 AT91C_BASE_AIC->AIC_IDCR = 0xffffffff;     // mask all interrupts
 asm volatile (
  // remap again
  "LDR R1, .MC_BASE \n\t"
  "MOV R2, #1   \n\t"
  "STR R2, [R1]  \n\t"

  // go to Reset vector
  "BIC R0, R0   \n\t"
  "LDR R0, .STARTUP \n\t" // optional but I can't reload the SAM-BA now, 
with my program sometimes crashed with free heap kernel panic
  "BX  R0    \n\t" // Thumb to ARM mode

  ".align 2    \n\t"
  ".STARTUP:    \n\t"
  ".word "RESET_ADDR"  \n\t"
  ".MC_BASE:    \n\t"
  ".word 0xFFFFFF00  \n\t"
 );
#endif
 AT91F_WDTRestart(AT91C_BASE_WDTC);      // restart watchdog
 AT91F_WDTSetMode(AT91C_BASE_WDTC, AT91C_WDTC_WDRSTEN); // enable watchdog
 //DBGU_FNTR, AT91C_US_FORCE_NTRST
 while (1);     // halt until reset
}

best regards
Janusz U.




More information about the En-Nut-Discussion mailing list