Atmega128(l) – Rainbow Electronics ATmega128L User Manual

Page 52

Advertising
background image

52

ATmega128(L)

2467B–09/01

1.

In the same operation, write a logic one to WDCE and WDE. A logic one must be
written to WDE even though it is set to one before the disable operation starts.

2.

Within the next four clock cycles, write a logic 0 to WDE. This disables the
watchdog.

In safety level 2, it is not possible to disable the Watchdog Timer, even with the algo-
rithm described above.

See “Timed Sequences for Changing the Configuration of the

Watch Dog Timer” on page 53.

• Bits 2..0 - WDP2, WDP1, WDP0: Watchdog Timer Prescaler 2, 1, and 0

The WDP2, WDP1, and WDP0 bits determine the Watchdog Timer prescaling when the
Watchdog Timer is enabled. The different prescaling values and their corresponding
Timeout Periods are shown in

Table 22.

Note:

1. Values are guidelines only. Actual values are TBD.

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.

Table 22. Watchdog Timer Prescale Select

(1)

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

TBD

16 ms

0

0

1

32K

TBD

32 ms

0

1

0

64K

TBD

64 ms

0

1

1

128K

TBD

0.13 s

1

0

0

256K

TBD

0.26 s

1

0

1

512K

TBD

0.5 s

1

1

0

1,024K

TBD

1.0 s

1

1

1

2,048K

TBD

2.0 s

Assembly Code Example

WDT_off:

; Write logical one to WDCE and WDE

ldi

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)

{

/* Write logical one to WDCE and WDE */

WDTCR = (1<<WDCE) | (1<<WDE);

/* Turn off WDT */

WDTCR = 0x00;

}

Advertising