Feeding watch dog on LPC11U24

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Tobias Zvonc on Thu Sep 25 08:19:32 MST 2014

I'm working on a second bootloader for LPC11U24, which uses USB HID for writing application to flash. I'm using LPCopen driver for LPC11Uxx.

To make long story short, I initialize USB interface, watch dog and SysTick timer. The idea was to feed watch dog timer from SysTick interrupt handler every 100 ms (Watch dog timer constant is for 2 seconds WD timer period). However, if I do that, microcontroller is reseted for 2, 3 or more times as soon as it initializes. The worst part is that this varies - sometimes after reset everything is good, sometimes MCU is reseted for 2 or more times in a row.

If I remove feeding watch dog from SysTick interrupt handler and feed it from while() loop in main(), everything is good. And if I remove feeding watch dog, MCU is reseted exactly every two seconds, and that confirms that watch dog is initialized correctly.

Does anybody have experience with this? I spent a day an a half trying to figure this out, and it doesn't make sense at all.

Here is relevant part of the code:

void WDT_IRQHandler(void)
    if(Chip_WWDT_GetStatus(LPC_WWDT) & WWDT_WDMOD_WDTOF)

void SysTick_Handler(void)
    // If we feed Watch dog from here, reset happens 2 or 3 (or more) times
    // in a row (every time different).

    if ( _g_IAPStarted ){
        Chip_GPIO_SetPinToggle(LPC_GPIO, PIN_LED2_RED);

int main(void)
    uint16_t calculatedCRC;
    volatile unsigned int delay;
    /* Initialize board and chip */
    // LED signals we are in bootloader.

    #ifndef DEBUG
    SysTick_Config(SystemCoreClock/10); // frequency of SysTick interrupt is 10 Hz (period = 100 ms)

    // Wait 5 seconds before attempting to start user-application
    while( _g_BootloaderTimeout_100ms ){

} /* end main() */

void WatchdogInitialize(void)
    #define WD_TIMEOUT_SEC  ( 2 )
    // Clear WD timeout flag
    Chip_WWDT_ClearStatusFlag(LPC_WWDT, WWDT_WDMOD_WDTOF);
    /* Watchdog config */
    // WD clk source - IRC oscilator (12 MHz)
    // wd_clk_freq = 12 MHz / 4 = 3 MHz
    // Watchdog timeout set to WD_TIMEOUT_SEC second
    Chip_WWDT_SetTimeOut( LPC_WWDT, (3000000*WD_TIMEOUT_SEC) );
    Chip_WWDT_SetWarning( LPC_WWDT, 0 );
    // Don't reset MCU, only generate an interrupt
    Chip_WWDT_Start(LPC_WWDT);    // (sets WD option WDEN)