Download avr-libc Reference Manual

Transcript
5.8
Watchdog timer handling
5.8
Watchdog timer handling
5.8.1
Detailed Description
#include <avr/wdt.h>
This header file declares the interface to some inline macros handling the watchdog
timer present in many AVR devices. In order to prevent the watchdog timer configuration from being accidentally altered by a crashing application, a special timed sequence
is required in order to change it. The macros within this header file handle the required
sequence automatically before changing any value. Interrupts will be disabled during
the manipulation.
Note:
Depending on the fuse configuration of the particular device, further restrictions
might apply, in particular it might be disallowed to turn off the watchdog timer.
Defines
•
•
•
•
•
•
•
•
•
•
•
#define wdt reset() asm
volatile (”wdr”)
#define wdt enable(timeout) wdt write((timeout) | BV(WDE))
#define wdt disable() wdt write(0)
#define WDTO 15MS 0
#define WDTO 30MS 1
#define WDTO 60MS 2
#define WDTO 120MS 3
#define WDTO 250MS 4
#define WDTO 500MS 5
#define WDTO 1S 6
#define WDTO 2S 7
5.8.2
5.8.2.1
Define Documentation
#define wdt disable() wdt write(0)
Disable the watchdog timer, if possible. This attempts to turn off the WDE bit in the
WDTCR register.
5.8.2.2
#define wdt enable(timeout) wdt write((timeout) | BV(WDE))
Enable the watchdog timer, configuring it for expiry after timeout (which is a combination of the WDP0 through WDP2 to write into the WDTCR register).
See also the symbolic constants WDTO 15MS et al.
Generated on Fri Apr 23 15:00:23 2004 for avr-libc by Doxygen
24