![Atmel AVR132 Application Note Download Page 8](http://html1.mh-extra.com/html/atmel/avr132/avr132_application-note_3003535008.webp)
8
AVR 132 Application Note
2551A–AVR–11/03
grammed only. If the WDTON fuse is programmed, the WDT System Reset Mode is
always enabled. How to change the fuse settings is described in the device datasheets.
If the WDT is intentionally used in the application and a system reset occurs, the startup
code should have a scheme for handling the WDT Reset Flag. The easiest solution is to
just ignore the flag and continue as usual. This approach saves the system from bugs
appearing occasionally, but has no way of handling repeated or persistent errors.
A possible extension is to keep a WDT system reset counter in non-volatile memory.
The startup code should then shut down the system safely and notify the operator if this
counter exceeds a predefined limit. Using some sort of system clock tick (backed up in
non-volatile memory), the startup code can also try to detect repeated resets over a
fixed period of time.
If parameter backup is used, the startup code should check the Write Complete flag
described in the Parameter Backup section and try to restore the system to a safe state,
or at least be able to supply some debugging information to the operator.
Changing the WDT
Configuration
To prevent accidental changes to the WDT configuration, special timed sequences are
needed to disable WDT System Reset Mode or change the timeout period.
To disable the WDT System Reset Mode, the Watchdog Change Enable bit must be set
within four CPU clock cycles prior to the disabling. If not, the WDT System Reset Mode
will stay enabled. If the WDTON fuse is programmed the WDT System Reset Mode is
always enabled.
To change the timeout period, the Watchdog Change Enable bit must be set within four
CPU clock cycles prior to changing the timeout value. It is however not recommended to
change the timeout period during normal operation. This should be done once in the ini-
tialization code.
If the WDTON fuse is unprogrammed on ATtiny13 and ATtiny2313, it is possible to
change the WDT timeout period without following the timed sequence.
Changing the WDT Interrupt Mode setting or enabling the WDT System Reset Mode
needs no special considerations.
Interrupts should be disabled when changing the configuration. This ensures that no
interrupts occur, causing the 4-cycle limit to expire.
Flowcharts for changing the WDT configuration are shown in Figure 6.