![Atmel AVR132 Application Note Download Page 2](http://html1.mh-extra.com/html/atmel/avr132/avr132_application-note_3003535002.webp)
2
AVR 132 Application Note
2551A–AVR–11/03
Theory
When the Enhanced Watchdog Timer (WDT) period has expired, a WDT timeout
occurs. The timeout period is adjusted using a configurable prescaler, which divides the
WDT oscillator clock by a constant factor. Executing the WDR (Watchdog Reset)
instruction resets the timer value. The application software using the WDT must be
designed so that it executes the WDR instruction periodically whenever it decides that
the system still operates correctly. The timer value is automatically reset on system
reset and when disabling the WDT.
The Enhanced Watchdog Timer has three modes of operation. When operating in WDT
System Reset Mode, a WDT timeout causes a system reset. If WDT Interrupt Mode and
global interrupts are enabled, a WDT timeout sets the WDT Interrupt Flag and executes
the WDT Interrupt handler, instead of resetting the system. If both WDT System Reset
Mode and WDT Interrupt Mode are enabled, the first WDT timeout is handled as if only
WDT Interrupt Mode was enabled. Then WDT Interrupt Mode is disabled automatically
and the WDT is back in only WDT System Reset mode.
Figure 1 on page 3 shows what happens when a WDT timeout occurs. The dotted boxes
describe actions performed by the system. The solid lined boxes describe actions to be
performed by the application
When using the Enhanced Watchdog Timer it is important to know that if the Watchdog
Always On (WDTON) fuse is programmed, the only possible operation mode is WDT
System Reset Mode. This security feature prevents software from enabling the WDT
Interrupt Mode unintentionally, which could disable the WDT System Reset functionality.
When the WDTON fuse is unprogrammed, the WDT Interrupt Mode can be used as
described in this document.
As mentioned above, the WDT is independent from the rest of the system. It has its own
internal 128 kHz oscillator, which runs as long as one of the WDT operating modes is
enabled. This ensures safe operation even if the main CPU oscillator fails.
Even if the software designers never intended to use the WDT, it could be enabled unin-
tentionally, e.g. by a runaway pointer or brown-out condition. Therefore the startup code
should always check the Reset Flags and take appropriate action if a WDT System
Reset has occurred, even if the application does not use the WDT.
The various settings and functions can be combined to use the WDT for different pur-
poses. The most important setups are described in the following sections.