avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] Disabling the Watchdog


From: Bill Rochat
Subject: [avr-libc-dev] Disabling the Watchdog
Date: 28 Jan 2003 22:27:59 -0000

The latest (and prior versions?) compiler generates the following code to 
disable the watchdog --- wdt_disable()---:

Outside interrupt routines:

in __tmp_reg__,__SREG__
cli
wdr
out 33,r24
out __SREG__,__tmp_reg__
out 33,r18 

// 33 is the WDTCR 

Inside interrupt routines:

ldi r24,lo8(24) 
ldi r25,hi8(24) 
out 33, r24 
out 33, __zero_reg__ 

If the user is using any watchdog timeout other than 17ms, the interrupt 
version of the watchdog disable may actually cause a watchdog reset! To prevent 
this, the WDR instruction should be added in front of the interrupt code as in 
the non-interrupt code, or the prescaler bits should be preserved during the 
disable operation. In 'C' the user can avoid the problem by issuing a 
wdt_reset() instruction just before the wdt_disable() instruction.

In other words, any time you wish to disable the watchdog inside an interrupt 
routine use the following:

wdt_reset();
wdt_disable();
-- 
Bill Rochat
President
R&R Technologies, Inc.
621 SW Alder St #380-C
Portland OR 97205
(503)459-1153
address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]