Datasheet

Table Of Contents
46
2570N–AVR–05/11
ATmega325/3250/645/6450
The following code example shows one assembly and one C function for turning off the WDT.
The example assumes that interrupts are controlled (e.g. by disabling interrupts globally) so that
no interrupts will occur during execution of these functions.
Note: 1. See “About Code Examples” on page 9.
11.9 Timed Sequences for Changing the Configuration of the Watchdog Timer
The sequence for changing configuration differs slightly between the two safety levels. Separate
procedures are described for each level.
Table 11-2. Watchdog Timer Prescale Select
WDP2 WDP1 WDP0
Number of WDT
Oscillator Cycles
Typical Time-out
at V
CC
= 3.0V
Typical Time-out
at V
CC
= 5.0V
0 0 0 16K cycles 17.1ms 16.3ms
0 0 1 32K cycles 34.3ms 32.5ms
0 1 0 64K cycles 68.5ms 65ms
011 128K cycles 0.14s 0.13s
1 0 0 256K cycles 0.27s 0.26s
1 0 1 512K cycles 0.55s 0.52s
1 1 0 1,024K cycles 1.1s 1.0s
111 2,048K cycles 2.2s 2.1s
Assembly Code Example
(1)
WDT_off:
; Reset WDT
wdr
; Write logical one to WDCE and WDE
in r16, WDTCR
ori r16, (1<<WDCE)|(1<<WDE)
out WDTCR, r16
; Turn off WDT
ldi r16, (0<<WDE)
out WDTCR, r16
ret
C Code Example
(1)
void WDT_off(void)
{
/* Reset WDT */
__watchdog_reset();
/* Write logical one to WDCE and WDE */
WDTCR |= (1<<WDCE) | (1<<WDE);
/* Turn off WDT */
WDTCR = 0x00;
}