lpcware

No reset by WDT

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Thucydides on Tue May 29 03:27:46 MST 2012
Hello,
I used WDT reset on LPC1343 but the expected reset didn't occur.
Firstly I set the clock frequency of the watchdog oscillator by setting WDTOSCCTRL register in the SYSCON.
(just like described from p.19 to 20 in the user.manual.lpc13xx.pdf)
DIVSEL=11111 (it means 2 × (1 + DIVSEL) = 64)
LPC_SYSCON->WDTOSCCTRL = 0x03F;
and
FREQSEL = 0001 (Fclkana = 0.5 MHz)
So I think wdt_osc_clk will be 7.8KHz (perhaps right?)
But before it I set Enable clock to WDT by setting
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<15);

And powered Watchdog oscillator in the Power-down configuration register (PDRUNCFG).
LPC_SYSCON->PDRUNCFG &= ~(0x1<<6);

Selected watchdog oscillator.
LPC_SYSCON->WDTCLKSEL = 0x02;

Updated clock
LPC_SYSCON->WDTCLKUEN = 0x01;
LPC_SYSCON->WDTCLKUEN = 0x00;
LPC_SYSCON->WDTCLKUEN = 0x01;

Wait until updated
while ( !(LPC_SYSCON->WDTCLKUEN & 0x01) );

Divided by 100 (it will be 78Hz?)
LPC_SYSCON->WDTCLKDIV = 0x64;

Enable WDT_IRQ
NVIC_EnableIRQ(WDT_IRQn);

I set feed value
LPC_WDT->TC = WDT_FEED_VALUE;
I set certain value (78*256*4) for the WDT_FEED_VALUE referring p.277 to p.280.

Enabled Watchdog and WDT reset in the Watchdog Mode register (WDMOD).
LPC_WDT->MOD = WDEN | WDRESET;

And feed
LPC_WDT->FEED = 0xAA;
LPC_WDT->FEED = 0x55;

I hope these procedures are correct.

Firstly I left feed in while loop but WDT reset didn't occur.

I show all codes.

#define WDEN                 (0x1<<0)
#define WDRESET               (0x1<<1)
#define WDT_FEED_VALUE        78*256*4

void WDTFeed(void)
{
  LPC_WDT->FEED = 0xAA;        // Feeding sequence
  LPC_WDT->FEED = 0x55;
  return;
}

int main(void)
{
    // Enable clock to WDT
    LPC_SYSCON->SYSAHBCLKCTRL |= (1<<15);
    LPC_SYSCON->WDTOSCCTRL = 0x03F; // 7.8kHz
    LPC_SYSCON->PDRUNCFG &= ~(0x1<<6);
    // Select watchdog oscillator
    LPC_SYSCON->WDTCLKSEL = 0x02;
    // Update clock
    LPC_SYSCON->WDTCLKUEN = 0x01;       
    LPC_SYSCON->WDTCLKUEN = 0x00;
    LPC_SYSCON->WDTCLKUEN = 0x01;
    // Wait until updated
    while ( !(LPC_SYSCON->WDTCLKUEN & 0x01) );
    // Divided by 100 (78Hz)       
    LPC_SYSCON->WDTCLKDIV = 0x64;
    NVIC_EnableIRQ(WDT_IRQn);
    LPC_WDT->TC = WDT_FEED_VALUE;
    LPC_WDT->MOD = WDEN | WDRESET;
    // Feed
    LPC_WDT->FEED = 0xAA;       
    LPC_WDT->FEED = 0x55;

    while (1)
    {
        // I comment outed WDT feed sequence
        WDTFeed();       

    }

}

I thought WDT reset necessarily occur since I omitted the Feed.
But I couldn't find the WDT reset.
Someone knows what is wrong?

Thanks,

Outcomes