beautypg.com

Attiny2313 – Rainbow Electronics ATtiny2313 User Manual

Page 41

background image

41

ATtiny2313

2543A–AVR–08/03

• Bit 6 – WDIE: Watchdog Timeout Interrupt Enable

When this bit is written to one, WDE is cleared, and the I-bit in the Status Register is set,
the Watchdog Time-out Interrupt is enabled. In this mode the corresponding interrupt is
executed instead of a reset if a timeout in the Watchdog Timer occurs.

If WDE is set, WDIE is automatically cleared by hardware when a time-out occurs. This
is useful for keeping the Watchdog Reset security while using the interrupt. After the
WDIE bit is cleared, the next time-out will generate a reset. To avoid the Watchdog
Reset, WDIE must be set after each interrupt.

• Bit 4 – WDCE: Watchdog Change Enable

This bit must be set when the WDE bit is written to logic zero. Otherwise, the Watchdog
will not be disabled. Once written to one, hardware will clear this bit after four clock
cycles. Refer to the description of the WDE bit for a Watchdog disable procedure. This
bit must also be set when changing the prescaler bits. See “Timed Sequences for
Changing the Configuration of the Watchdog Timer” on page 44.

• Bit 3 – WDE: Watchdog Enable

When WDE is written to logic one, the Watchdog Timer is enabled, and if WDE is written
to logic zero, the Watchdog Timer function is disabled. WDE can only be cleared if the
WDCE bit has logic level one. To disable an enabled Watchdog Timer, the following pro-
cedure must be followed:

1.

In the same operation, write a logic one to WDCE and WDE. A logic one must be
written to WDE even though it is set to one before the disable operation starts.

2.

Within the next four clock cycles, write a logic 0 to WDE. This disables the
Watchdog.

In safety level 2, it is not possible to disable the Watchdog Timer, even with the algo-
rithm described above. See “Timed Sequences for Changing the Configuration of the
Watchdog Timer” on page 44.

In safety level 1, WDE is overridden by WDRF in MCUSR. See “MCU Status Register –
MCUSR” on page 38
for description of WDRF. This means that WDE is always set when
WDRF is set. To clear WDE, WDRF must be cleared before disabling the Watchdog
with the procedure described above. This feature ensures multiple resets during condi-
tions causing failure, and a safe start-up after the failure.

Warning:If the watchdog timer is not be used in the application, it is important to go through a

watchdog disable procedure in the initialization of the device. If the Watchdog is acciden-
tally enabled, for example by a runaway pointer or brown-out condition, the device will be
reset, which in turn will lead to a new watchdog reset. To avoid this situation, the applica-
tion software should always clear the WDRF flag and the WDE control bit in the
initialization routine.

Table 20. Watchdog Timer Configuration

WDE

WDIE

Watchdog Timer State

Action on Time-out

0

0

Stopped

None

0

1

Running

Interrupt

1

0

Running

Reset

1

1

Running

Interrupt