Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Need help setting up the watchdog timer to generate an interrupt

2005-03-14 by david_z_lawson

I'm trying to get the watchdog timer on the 2138 to timeout and
generate an interrupt. If I have the reset bit set in WDMOD it does
reset after 5 seconds, but I can't get the chip to execute the
interrupt (can't break in the interrupt routine). How should you
handle a watchdog interrupt? I'm not sure how you clear it.

Can someone look at the setup of the watchdog timer and tell me if I'm
doing it correctly?


#define WD_TIMEOUT 5.0		// 5 second watchdog timeout
void __attribute__((interrupt("IRQ"))) wdi(void);

//-------------------------------------------------------
//-------------------------------------------------------

init_watchdog(void)  {

   VICIntSelect &= ~0x00000001;	// watchdog selected as IRQ, not FIQ
   VICVectAddr4 = (unsigned long)wdi;	// set interrupt in slot 4
   VICVectCntl4 = 0x20;		// use it for watchdog interrupt
   VICIntEnable = 0x00000001;	// enable watchdog interrupt

   WDTC = (unsigned long) (.5 + WD_TIMEOUT / (4.0*PPERIOD) );
   WDMOD = 0x01;	// 8 bits, wden, interrupt but no reset

   WDFEED = 0xaa;	// 8 bits
   WDFEED = 0x55;	// 8 bits

   return;
}

//-------------------------------------------------------
//-------------------------------------------------------

void __attribute__((interrupt("IRQ"))) wdi(void)  {

   VICVectAddr = 0;		// acknowledge interrupt

}

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.