C161U
The Watchdog Timer (WDT)
Preliminary Data Sheet
356
02.2000
PRELIMINARY
PRE
LI
M
INAR
Y
- E
XC
ER
PT
-
When the watchdog timer is not disabled via instruction DISWDT, it will continue
counting up, even during Idle Mode. If it is not serviced via the instruction SRVWDT by
the time the count reaches FFFFH the watchdog timer will overflow and cause an internal
reset. This reset will pull the external reset indication pin RSTOUT low. It differs from a
software or external hardware reset in that bit WDTR (Watchdog Timer Reset Indication
Flag) of register WDTCON will be set. A hardware reset or the SRVWDT instruction will
clear this bit. Bit WDTR can be examined by software in order to determine the cause of
the reset.
A watchdog reset will also complete a running external bus cycle before starting the
internal reset sequence if this bus cycle does not use READY or samples READY active
(low) after the programmed waitstates. Otherwise the external bus cycle will be aborted.
Note: After a hardware reset that activates the Bootstrap Loader the watchdog timer will
be disabled.
To prevent the watchdog timer from overflowing, it must be serviced periodically by the
user software. The watchdog timer is serviced with the instruction SRVWDT, which is a
protected 32-bit instruction. Servicing the watchdog timer clears the low byte and reloads
the high byte of the watchdog timer register WDT with the preset value from bitfield
WDTREL which is the high byte of register WDTCON. Servicing the watchdog timer will
also reset bit WDTR. After being serviced the watchdog timer continues counting up from
the value (<WDTREL> * 2
8). Instruction SRVWDT has been encoded in such a way that
the chance of unintentionally servicing the watchdog timer (eg. by fetching and executing
a bit pattern from a wrong location) is minimized. When instruction SRVWDT does not
match the format for protected instructions the Protection Fault Trap will be entered,
rather than the instruction be executed.
The time period for an overflow of the watchdog timer is programmable in two ways:
the input frequency to the watchdog timer can be selected via bit WDTIN in register
WDTCON to be either fCPU/2 or fCPU/128.
the reload value WDTREL for the high byte of WDT can be programmed in register
WDTCON.
The period PWDT between servicing the watchdog timer and the next overflow can
therefore be determined by the following formula:
Note: For safety reasons, the user is advised to rewrite WDTCON each time before the
watchdog timer is serviced.
P
WDT =
f
CPU
2
(1 + <WDTIN>*6) * (216 - <WDTREL> * 28)