ATTIny13-12PI ATMEL Corporation, ATTIny13-12PI Datasheet - Page 37

no-image

ATTIny13-12PI

Manufacturer Part Number
ATTIny13-12PI
Description
8-bit AVR Microcontroller with 1K Bytes In-System Programmable Flash
Manufacturer
ATMEL Corporation
Datasheet
Watchdog Timer Control
Register - WDTCR
2535B–AVR–01/04
Watchdog System Reset Flag (WDRF) and the WDE control bit in the initialisation rou-
tine, even if the Watchdog is not in use.
The following code example shows one assembly and one C function for changing the
time-out value of the Watchdog Timer.
Note:
Note: 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.
Bit
Read/Write
Initial Value
Assembly Code Example
C Code Example
WDT_Prescaler_Change:
void WDT_Prescaler_Change(void)
{
}
; Turn off global interrupt
cli
; Reset Watchdog Timer
wdr
; Start timed sequence
in
ori
out
; --
; Set new prescaler(time-out) value = 64K cycles (~0.5 s)
ldi
out
; --
; Turn on global interrupt
sei
ret
__disable_interrupt();
__watchdog_reset();
/* Start timed sequence */
WDTCR |= (1<<WDCE) | (1<<WDE);
/* Set new prescaler(time-out) value = 64K cycles (~0.5 s) */
WDTCR = (1<<WDE) | (1<<WDP2) | (1<<WDP0);
__enable_interrupt();
1. The example code assumes that the part specific header file is included.
WDIF
r16, WDTCR
r16, (1<<WDCE) | (1<<WDE)
WDTCR, r16
Got four cycles to set the new values from here -
r16, (1<<WDE) | (1<<WDP2) | (1<<WDP0)
WDTCR, r16
Finished setting new values, used 2 cycles -
R/W
7
0
(1)
WDIE
R/W
6
0
(1)
WDP3
R/W
5
0
WDCE
R/W
4
0
WDE
R/W
X
3
WDP2
R/W
2
0
WDP1
R/W
1
0
ATtiny13
WDP0
R/W
0
0
WDTCR
37

Related parts for ATTIny13-12PI