Datasheet

46
ATmega325/3250/645/6450
2570K–AVR–04/07
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 8.
Table 21. 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.1 ms 16.3 ms
0 0 1 32K cycles 34.3 ms 32.5 ms
0 1 0 64K cycles 68.5 ms 65 ms
0 1 1 128K cycles 0.14 s 0.13 s
1 0 0 256K cycles 0.27 s 0.26 s
1 0 1 512K cycles 0.55 s 0.52 s
1 1 0 1,024K cycles 1.1 s 1.0 s
1 1 1 2,048K cycles 2.2 s 2.1 s
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;
}