EmbeddedRelated.com
Forums

does watchdog work ?

Started by douglasbolton September 15, 2004
I can't get the watchdog timer to work.

I set up with the following

// set watchdog to be 1 second
WDTC = 15000000;
// enable the watchdog interrupt
WDMOD = 1;

WDFEED = 0xAA;
WDFEED = 0x55;

I then feed every loop of code. Even if I continually feed after set
up the WDTOF and WDINT flags get set.




An Engineer's Guide to the LPC2100 Series

Initialization:

/* Setting watchdog work mode */
WDMOD |= WDMOD_WDEN;
WDMOD |= WDMOD_WDRESET;
/* Dropping watchdog timeout flag */
WDMOD &= ~WDMOD_WDTOF;
/* Setting watchdog timeout */
WDTC = WatchdogTimeout;

WDFEED = 0xAA;
WDFEED = 0x55;

-----------
Reset each cycle:

WDTC &= ~WDMOD_WDTOF;
/* Feeding 0xAA, 0x55 to restart watchdog */
WDFEED = WDFEED_WDFEED(0xAA);
WDFEED = WDFEED_WDFEED(0x55);

This code is from our Watchdog driver. We've successfully test it.



A side note to all those working on the LPC22xx chips and using
external memory: When the watchdog times out it will try to access
vector memory at relative 0x00000000 using the memory attached to CS0
(instead of address 0 of the internal flash memory). --- In , "cd_racer2" <cd_racer@m...> wrote:
> Initialization:
>
> /* Setting watchdog work mode */
> WDMOD |= WDMOD_WDEN;
> WDMOD |= WDMOD_WDRESET;
> /* Dropping watchdog timeout flag */
> WDMOD &= ~WDMOD_WDTOF;
> /* Setting watchdog timeout */
> WDTC = WatchdogTimeout;
>
> WDFEED = 0xAA;
> WDFEED = 0x55;
>
> -----------
> Reset each cycle:
>
> WDTC &= ~WDMOD_WDTOF;
> /* Feeding 0xAA, 0x55 to restart watchdog */
> WDFEED = WDFEED_WDFEED(0xAA);
> WDFEED = WDFEED_WDFEED(0x55);
>
> This code is from our Watchdog driver. We've successfully test
it.



FWIW:
The following routine worked for me. I used P0.4 &5 to be able to
see an i/o pin assert and de-assert using the Keil MCB2100(no
expansion bus):
void init_WDT (void){
WDTC = 0xFF;
WDMOD= 0x03;
WDFEED=0xAA;
WDFEED=0x55;
}
void init_iopins4and5 (void){
PINSEL0=0x0;
IODIR0=0x00000030;
IOCLR0 = 0x00000030;
}

long count;
long spare;

int main (void) {
count=0x0;
spare=0x0;
/* Establish Port 0 bit 4 and 5 as outputs and
de-assert both */

init_iopins4and5();
if (WDMOD==0x04)
IOSET0=0x00000020; //P0.05 set
else
spare++;/*startup the watchdog timer
- watchdog interrupt enable = 1
- watchdog reset enable = 1
SO when WDEN and Watchdog timeout happens, a hardware reset should
occur
*/
init_WDT();

if (WDMOD==0x03)
IOSET0 =0x00000010; //set P0.04
else
spare++;

while (1);
Regards,
Will
}--- In , "markcrow" <mcrow@p...> wrote:
> A side note to all those working on the LPC22xx chips and using
> external memory: When the watchdog times out it will try to access
> vector memory at relative 0x00000000 using the memory attached to
CS0
> (instead of address 0 of the internal flash memory). > --- In , "cd_racer2" <cd_racer@m...> wrote:
> > Initialization:
> >
> > /* Setting watchdog work mode */
> > WDMOD |= WDMOD_WDEN;
> > WDMOD |= WDMOD_WDRESET;
> > /* Dropping watchdog timeout flag */
> > WDMOD &= ~WDMOD_WDTOF;
> > /* Setting watchdog timeout */
> > WDTC = WatchdogTimeout;
> >
> > WDFEED = 0xAA;
> > WDFEED = 0x55;
> >
> > -----------
> > Reset each cycle:
> >
> > WDTC &= ~WDMOD_WDTOF;
> > /* Feeding 0xAA, 0x55 to restart watchdog */
> > WDFEED = WDFEED_WDFEED(0xAA);
> > WDFEED = WDFEED_WDFEED(0x55);
> >
> > This code is from our Watchdog driver. We've successfully test
> it.