Datasheet
22.3.2.1 Reconfiguring the Watchdog
In some cases (such as when supporting a bootloader function), users may want to
reconfigure or disable the watchdog without forcing a reset first. By setting the
WDOG_CS1[UPDATE] bit to a 1 on the initial configuration of the watchdog after a
reset, users can reconfigure the watchdog at any time by executing an unlock sequence.
(Conversely, if the WDOG_CS1[UPDATE] remains 0, the only way to reconfigure the
watchdog is by initiating a reset.) The unlock sequence is similar to the refresh sequence
but uses different values.
22.3.2.2 Unlocking the Watchdog
The unlock sequence is a write to the WDOG_CNTH:L registers of 0xC520 followed by
0xD928 within 16 bus clocks at any time after the watchdog has been configured. On
completing the unlock sequence, the user must reconfigure the watchdog within 128 bus
clocks; otherwise, the watchdog forces a reset to the MCU.
NOTE
Due to 128 bus clocks requirement for reconfiguring the
watchdog, some delays must be inserted before executing
STOP or WAIT instructions after reconfiguring the watchdog.
This ensures that the watchdog's new configuration takes effect
before MCU enters low power mode. Otherwise, the MCU may
not be waken up from low power mode.
22.3.2.3 Example code: Reconfiguring the Watchdog
The following code segment shows an example reconfiguration of the WDOG module.
/* Initialize watchdog with ~1-kHz clock source, ~1s time-out */
DisableInterrupts; // disable global interrupt
WDOG_CNT = 0xC520; // write the 1st unlock word
WDOG_CNT = 0xD928; // write the 2nd unlock word
WDOG_TOVAL = 1000; // setting timeout value
WDOG_CS2 = WDOG_CS2_CLK_MASK; // setting 1-kHz clock source
WDOG_CS1 = WDOG_CS1_EN_MASK; // enable counter running
EnableInterrupts; // enable global interrupt
Functional description
MC9S08PA60 Reference Manual, Rev. 1, 9/2012
586 Freescale Semiconductor, Inc.
