ATmega88PA Automotive Atmel Corporation, ATmega88PA Automotive Datasheet - Page 54

no-image

ATmega88PA Automotive

Manufacturer Part Number
ATmega88PA Automotive
Description
Manufacturer
Atmel Corporation
54
Atmel ATmega48PA/88PA/168PA [Preliminary]
The following code example shows one assembly and one C function for changing the
time-out value of the Watchdog Timer.
Assembly Code Example
C Code Example
Notes:
WDT_Prescaler_Change:
void WDT_Prescaler_Change(void)
{
}
; Turn off global interrupt
cli
; Reset Watchdog Timer
wdr
; Start timed sequence
lds r16, WDTCSR
ori
sts WDTCSR, r16
; --
; Set new prescaler(time-out) value = 64K cycles (~0.5 s)
ldi
sts WDTCSR, r16
; --
; Turn on global interrupt
sei
ret
__disable_interrupt();
__watchdog_reset();
/* Start timed
WDTCSR |= (1<<WDCE) | (1<<WDE);
/* Set new prescaler(time-out) value = 64K cycles (~0.5 s) */
WDTCSR
__enable_interrupt();
1. See
2. The Watchdog Timer should be reset before any change of the WDP bits, since a change
in the WDP bits can result in a time-out when switching to a shorter time-out period.
r16, (1<<WDCE) | (1<<WDE)
Got four cycles to set the new values from here -
r16, (1<<WDE) | (1<<WDP2) | (1<<WDP0)
Finished setting new values, used 2 cycles -
Section 6. “About Code Examples” on page 7
= (1<<WDE) | (1<<WDP2) | (1<<WDP0);
(1)
(1)
sequence */
9223B–AVR–09/11

Related parts for ATmega88PA Automotive