![Atmel AVR132 Application Note Download Page 3](http://html1.mh-extra.com/html/atmel/avr132/avr132_application-note_3003535003.webp)
3
AVR 132 Application Note
2551A–AVR–11/03
Figure 1. Event Sequence When a WDT Timeout Occurs
Using the WDT System
Reset Mode
Configuring the WDT to work as a system reset source only, is straightforward. Enable
the WDT System Reset Mode, set a reasonable timeout delay and off you go. If your ini-
tialization routines take longer than the WDT timeout period, they should execute the
WDR instruction at appropriate checkpoints during execution. If not, the code will never
reach its main loop before the WDT resets the system.
The timeout period must be chosen so that it is longer than the longest possible execu-
tion path through the main loop of your application. This includes expected interrupt
handlers as well. If your main loop is very large, several checkpoints could be inserted
inside the loop to allow a shorter timeout period.
Choosing the correct timeout period requires detailed knowledge of the timing charac-
teristics of your main loop. In many applications, the most robust approach could be to
choose a timeout period of several seconds. This will at least reset the system if it is
stuck in an infinite loop.
WDT timeout
WDT Interrupt Flag set
WDT Interrupt
Mode enabled ?
Global Interrupts
enabled ?
WDT Interrupt Flag
cleared
WDT System Reset
WDT Reset Flag set
Continue
Yes
No
Yes
No
Execute WDT
Interrupt Handler
WDT System Reset
Mode enabled
WDT System
Reset Mode
enabled ?
WDT Interrupt Mode
disabled
Yes
No