Datasheet

59
2490R–AVR–02/2013
ATmega64(L)
The following code examples show one assembly and one C function for turning off the WDT.
The examples assume that interrupts are controlled (for example, by disabling interrupts glob-
ally) so that no interrupts will occur during execution of these functions.
Assembly Code Example
WDT_off:
; reset WDT
wdr
in r16, WDTCR
ldi r16, (1<<WDCE)|(1<<WDE)
; Write logical one to WDCE and WDE
ori r16, (1<<WDCE)|(1<<WDE)
out WDTCR, r16
; Turn off WDT
ldi r16, (0<<WDE)
out WDTCR, r16
ret
C Code Example
void WDT_off(void)
{
/* Reset WDT*/
_WDRC();
/* Write logical one to WDCE and WDE */
WDTCR |= (1<<WDCE) | (1<<WDE);
/* Turn off WDT */
WDTCR = 0x00;
}