Watchdog Reset

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by pcalton on Thu Nov 07 11:18:08 MST 2013
I have been trying to add the watchdog to my application to reset the processor if the software hangs using the following setup routine

#define MHz(x) (x * 1000000)

#define WDT_MAX_TIME 5000 // 5 seconds (Max 5592)
#define WDT_MIN_TIME 1 // 1 millisecond

void Board_WWDT_Init(void)
// Windowed watchdog runs from internal RC osc at 12MHz with fixed div by 4 prescale.
// 24 bit counter decremented from timeout value to zero (reset core at zero)
// feed resets counter to timeout value
// feed with counter above window value results in a core reset
const uint32_t wdt_count_per_ms = (MHz(12) / 4) / 1000;
const uint32_t wdt_timeout = WDT_MAX_TIME * wdt_count_per_ms;
const uint32_t wdt_window = (WDT_MAX_TIME - WDT_MIN_TIME) * wdt_count_per_ms;

Chip_WWDT_SetTimeOut(LPC_WWDT, wdt_timeout);
Chip_WWDT_SetWindow(LPC_WWDT, wdt_window);

To test my setup I purposefully allowed the watchdog to expire, expecting the software to reset and restart. The software certainly stopped after 5 seconds, but didnt restart.

To check whether I had missed anything I loaded up the keil lpcopen peripheral example for the watchdog on a clean un-modded MCB4357 board

That application allows interaction via usart3 with the option to disable the feed and reset the device. When I selected this option the flashing led that indicated program life stopped and then to my surprise the LCD lit up showing MCB4300 Demo Example.

If I press the external reset button, the watchdog example starts again and runs until I select the option to disable feeding at which point the MCB4300 Demo Example appears. I can only assume that following the watchdog reset the processor is booting out of external memory even though there is a valid application in the internal flash.

Could someone please explain what is happening and how to rectify it so that the internal flash application starts following a watchdog reset?