// Initialisation (PNQPAR &= ~(0xc0)); // configure NQ 3 as input if (!((PORTIN_SETNQ & PORT_NQ_BIT3))) { // If NQ is not pulled down CWCR = (CWE | WATCHDOG_2_SEC | CWTA | CWTAVA | CWTIF); fnSetIntHandler(SW_WD_VECTOR, (unsigned char *)sw_wdog_timeout); IC_ICR_0_8 = (INTERRUPT_LEVEL_7 | INTERRUPT_PRIORITY_7); IC_IMRL_0 &= ~(SW_WDG_PIF_INT_L | MASK_ALL_INT); } else { CWCR = 0; // watchdog disabled } // Watchdog retrigger called every 200ms CWSR = 0x55; // retrigger the software watchdog CWSR = 0xaa; // using this two byte sequence // Watchdog interrupt static __interrupt__ void sw_wdog_timeout(void) { RESET_RCR = SOFT_RST; // command a soft reset of the board }
Note that when using the BDM with active watchdog, the watchdog will fire when a break is reached (I don't know of a method to freeze the watchdog in debug mode) and therefore the watchdog activation has been made conditional on a port input (NQ bit 3 in this case) so that a strap to ground disables the watchdog for the debugging session.
Regards
Alban fixed link.
Message Edited by Alban on 2007-02-11 07:04 PM