No reset by WDT

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

No reset by WDT

825 Views
lpcware
NXP Employee
NXP Employee
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,
0 Kudos
9 Replies

666 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed May 30 23:18:47 MST 2012

Quote: Thucydides
OK I write my source.
Originally I meant to set the WDT_FEED_VALUE to 2 sec like this but the result was different as I wrote before.
[COLOR=SandyBrown]#define WDT_FEED_VALUE        7800/2
[/COLOR]

/************* my source *********/
#include "lpc13xx.h"

#define WDEN                 (0x1<<0)
#define WDRESET               (0x1<<1)
#define WDTOF                 (0x1<<2)
#define WDINT                 (0x1<<3)
#define WDPROTECT             (0x1<<4)
[COLOR=DarkOrange]#define WDT_FEED_VALUE        276[/COLOR]
//#define WDT_FEED_VALUE // 277-280 :10secs // 276 : 2secs  // 275 : 1 sec
// #define WDT_FEED_VALUE        7800/2 // Originally 2secs

void WDTInit(void)
{
    LPC_SYSCON->SYSAHBCLKCTRL |= (1<<15);
    LPC_SYSCON->CLKOUTCLKSEL = 0x02;
    LPC_SYSCON->WDTOSCCTRL = 0x03F; // ~7.8kHz
    LPC_SYSCON->PDRUNCFG &= ~(0x1<<6);

    LPC_SYSCON->WDTCLKSEL = 0x02;
    LPC_SYSCON->WDTCLKUEN = 0x01;
    LPC_SYSCON->WDTCLKUEN = 0x00;
    LPC_SYSCON->WDTCLKUEN = 0x01;
    while ( !(LPC_SYSCON->WDTCLKUEN & 0x01) );
    LPC_SYSCON->WDTCLKDIV = 0x01;     // Divided by 1 (7.8KHz)

    NVIC_EnableIRQ(WDT_IRQn);
    LPC_WDT->TC = WDT_FEED_VALUE;   
    LPC_WDT->MOD = WDEN | WDRESET;

    LPC_WDT->FEED = 0xAA;
    LPC_WDT->FEED = 0x55;
}

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

int main(void)
{
    [COLOR=Red]while (1)
    {
        WDTInit();
        // commented out Feed sequence
        // WDTFeed();
    }[/COLOR]
}



Are you kidding?

Please start to export your projects: http://support.code-red-tech.com/CodeRedWiki/ImportExporthttp://support.code-red-tech.com/CodeRedWik...

Moving WDT_Init out of the endless while(1)  loop and using 7800/2 is generating a 2 sec WDT reset here (as calculated :)).

If that's not working in your code you have changed your project settings :mad:
0 Kudos

666 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Thucydides on Wed May 30 21:12:34 MST 2012

Quote: Zero
I've no idea what you are doing and what your actual settings are :confused:
If you want someone to check your code, just export and post it :eek:



OK I write my source.
Originally I meant to set the WDT_FEED_VALUE to 2 sec like this but the result was different as I wrote before.
#define WDT_FEED_VALUE        7800/2


/************* my source *********/
#include "lpc13xx.h"

#define WDEN                 (0x1<<0)
#define WDRESET               (0x1<<1)
#define WDTOF                 (0x1<<2)
#define WDINT                 (0x1<<3)
#define WDPROTECT             (0x1<<4)
#define WDT_FEED_VALUE        276
//#define WDT_FEED_VALUE // 277-280 :10secs // 276 : 2secs  // 275 : 1 sec
// #define WDT_FEED_VALUE        7800/2 // Originally 2secs

void WDTInit(void)
{
    LPC_SYSCON->SYSAHBCLKCTRL |= (1<<15);
    LPC_SYSCON->CLKOUTCLKSEL = 0x02;
    LPC_SYSCON->WDTOSCCTRL = 0x03F; // ~7.8kHz
    LPC_SYSCON->PDRUNCFG &= ~(0x1<<6);

    LPC_SYSCON->WDTCLKSEL = 0x02;
    LPC_SYSCON->WDTCLKUEN = 0x01;
    LPC_SYSCON->WDTCLKUEN = 0x00;
    LPC_SYSCON->WDTCLKUEN = 0x01;
    while ( !(LPC_SYSCON->WDTCLKUEN & 0x01) );
    LPC_SYSCON->WDTCLKDIV = 0x01;     // Divided by 1 (7.8KHz)

    NVIC_EnableIRQ(WDT_IRQn);
    LPC_WDT->TC = WDT_FEED_VALUE;   
    LPC_WDT->MOD = WDEN | WDRESET;

    LPC_WDT->FEED = 0xAA;
    LPC_WDT->FEED = 0x55;
}

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

int main(void)
{
    while (1)
    {
        WDTInit();
        // commented out Feed sequence
        // WDTFeed();
    }
}
0 Kudos

666 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed May 30 10:31:20 MST 2012
I've no idea what you are doing and what your actual settings are :confused:

If you want someone to check your code, just export and post it :eek:
0 Kudos

666 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Thucydides on Wed May 30 10:23:10 MST 2012

Quote: Zero


This time:

#define WDT_FEED_VALUE        78*256*4

is generating a 78*256*4[COLOR=Red]*4[/COLOR] = 319488 timer.

If it's clocked with 78Hz, your WDT resets after 319488 / 78 s = 4096 s = [COLOR=Red]1 hour, 8 minutes[/COLOR][COLOR=Black] :eek:

I would strongly recommend to use 7.8kHz without divider :)

There your minimal reset time is 256*4 / 7800 s = 0.13 s
and your maximal reset time 2^24 * 4 / 7800 s =  2.38 hours

[/COLOR]


Thank you for your advice.
Yes it was my misunderstanding to multiply WDCLK value.
And I thought that WDT_FEED_VALUE must be 7800 if I need 4 sec WDT.
But my expectation was fully betrayed.
I added 1 sec timer and I measured after how many second WDT work.
Under the condition WDT_FEED_VALUE=7800, the WDT didn't seem to work at least within few minutes.
So I increased the WDT_FEED_VALUE 1 by 1 from 256.
The result was as followings.
WDT_FEED_VALUE=275 : WDT started about 1 sec after
WDT_FEED_VALUE=276 : about 2 secs
WDT_FEED_VALUE=277 to 280 : about 10 secs

Someone explains the cause of this result?? and I hope someone checks in real.

Thanks,
0 Kudos

666 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed May 30 04:26:19 MST 2012

Quote: Thucydides
...Whether is it long or short is not the matter....



I'm not sure if you understand how WDT is working :confused:

Which time do you expect?

This time:

#define WDT_FEED_VALUE        78*256*4

is generating a 78*256*4[COLOR=Red]*4[/COLOR] = 319488 timer.

If it's clocked with 78Hz, your WDT resets after 319488 / 78 s = 4096 s = [COLOR=Red]1 hour, 8 minutes[/COLOR][COLOR=Black] :eek:

I would strongly recommend to use 7.8kHz without divider

There your minimal reset time is 256*4 / 7800 s = 0.13 s
and your maximal reset time 2^24 * 4 / 7800 s =  2.38 hours

Note: To check your real WDTCLOCK, use CLOCKOUT
//CLKOUT Pin PIO0_1 to monitor frequency
LPC_IOCON->PIO0_1    = (1<<0)|(1<<3);        //ext pullup needed!!
// Select the MAIN clock as the clock out selection since it's driving the core
LPC_SYSCON->CLKOUTCLKSEL = 0x02;    /* Select WDT clock */
LPC_SYSCON->CLKOUTUEN = 0x01;        /* Update clock */
LPC_SYSCON->CLKOUTUEN = 0x00;        /* Toggle update register once */
LPC_SYSCON->CLKOUTUEN = 0x01;
while ( !(LPC_SYSCON->CLKOUTUEN & 0x01) );        /* Wait until updated */
LPC_SYSCON->CLKOUTDIV = 1;            /* Divided by 1 */
And don't forget that this clock  is +- 40 % :rolleyes: My 7.8 kHz is a real 8.8 kHz.
[/COLOR]
0 Kudos

666 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Thucydides on Wed May 30 01:45:02 MST 2012
Hello,
Whether is it long or short is not the matter.
Even if I set to more short period, WDT reset don't occur.

LPC_SYSCON->WDTCLKDIV = 0x01;                    // Divided by 1 (7.8KHz)

How could I start WDT reset?
Thanks,



Quote: Zero
Are you aware that you reset time is somewhere at 2 1/2 minutes :eek:

0 Kudos

666 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed May 30 01:20:43 MST 2012

Quote: Thucydides
... but I couldn't realize WDT reset...



Are you aware that you reset time is somewhere at 2 1/2 minutes :eek:
0 Kudos

666 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Thucydides on Wed May 30 00:31:39 MST 2012
Hello,

Yes I did like this.

#define WDEN                 (0x1<<0)
#define WDRESET               (0x1<<1)
LPC_WDT->MOD = WDEN | WDRESET;

I omitted WDTFeed(); in the while loop, but I couldn't realize WDT reset.
I inserted WDTInit(); in the while loop but in vain too.
How should I do work WDT reset??
Thanks,



Quote: NXP_Europe
Hello Thucydides,

please try:

regVal = WDEN | WDRESET;
LPC_WWDT->MOD = regVal;

or

LPC_WDT->MOD = 0x00000003;


Did you use the WDT-routine from a code-bundle?

0 Kudos

666 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_Europe on Tue May 29 15:52:38 MST 2012
Hello Thucydides,

please try:

regVal = WDEN | WDRESET;
LPC_WWDT->MOD = regVal;

or

LPC_WDT->MOD = 0x00000003;


Did you use the WDT-routine from a code-bundle?
0 Kudos