lpcware

LPC1769 WatchDog

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by arturn on Sun May 05 05:30:23 MST 2013
Hi!

First of all I'm newbie in mbded technology ;)

I'm trying to implement a watchdog timer to wakeup board from deep sleep mode after certain time.

I've written the below code with info in UM10360 manual, but don't work right...

After firt call to WDT_IrqHandler, enter in "infinite loop".
I think is because    LPC_WDT->WDMOD &= ~(1<< 3);
don't restart WDINT...
  
void WatchDog_Init(uint32_t TimeOut)
{

    // Set the watchdog timer constant reload value
    LPC_WDT->WDTC =TimeOut * 256 * 4; // timeout value

    // Setup the Watchdog time operating mode in WDMOD register
    LPC_WDT->WDMOD = 0x5; // Watch dog enabled, reset disable , watchdog cleared by software.

    // Enable watchdow by writting 0xAA followed by 0x55 to WDFEED register
    // Reload the watchdog timer with the WDTC value.
    WatchDog_Fed();


     NVIC_EnableIRQ(WDT_IRQn);

}


static void WatchDog_Fed()
{
    // Enable watchdow by writting 0xAA followed by 0x55 to WDFEED register
    // Reload the watchdog timer with the WDTC value.
    LPC_WDT->WDFEED = 0xAA;
    LPC_WDT->WDFEED = 0x55;

}

void WDT_IRQHandler(void)
{
//    //LPC_WDT->WDMOD &= ~WDTOF;     /* clear the time-out interrupt flag */
//    LPC_WDT->WDMOD |= ( 0 << 2);     /* clear the time-out interrupt flag */

    if ( LPC_WDT->WDMOD & 1 << 2 )
    {
        m_count++;

        // TODO: Wake up CPU!
        WatchDog_Fed();
        LPC_WDT->WDMOD &= ~(1<< 3);        // Set bit timeout to 0 othertime.

    }
}

Outcomes