Specifications

8.4.4 Programming the Watchdog
The following functions show how to use the watchdog facility available through the Status and
Control registers.
It is worth noting that the Software Enable bit in the Watchdog Status and Control register does
not read back the value last written; it is the output from the error checking logic, so it will not
read back as enabled until two watchdog restarts have been performed (equally it will not display
disabled until two further restarts have been performed).
/* Status and control registers */
#define STATCTL_BASE 0x0210
#define WATCHDOG_STATCTL (STATCTL_BASE + 4)
#define WD_PAT_MASK 0x03
#define WD_PAT_1 0x02
#define WD_PAT_2 0x01
#define WD_ACTION_MASK 0x04
#define WD_ACTION_NMI 0x00
#define WD_ACTION_RST 0x04
#define WD_STATUS 0x08
#define WD_HW_DISABLE 0x10
#define WD_SW_ENABLE 0x20
/*****************************************************************************
* vEnableWatchdog: configure the watchdog for NMI or RESET on timeout
*
* RETURNS: none
*/
void vEnableWatchdog
(
UINT8 bTimeoutAction /* action on timeout: NMI or Reset */
)
{
UINT8 bTemp;
bTemp = inbyte (WATCHDOG_STATCTL);
bTemp &= ~WD_ACTION_MASK; /* set watchdog timeout action */
bTemp |= bTimeoutAction;
bTemp |= WD_SW_ENABLE; /* software enable of watchdog */
bTemp &= ~WD_PAT_MASK; /* clear the pat bits */
outbyte (WATCHDOG_STATCTL, bTemp | WD_PAT_1); /* set and pat twice */
outbyte (WATCHDOG_STATCTL, bTemp | WD_PAT_2);
outbyte (WATCHDOG_STATCTL, bTemp | WD_PAT_1);
} /* vEnableWatchdog () */
/*****************************************************************************
* vDisableWatchdog: de-configure the watchdog and disable
*
* RETURNS: none
*/
void vDisableWatchdog (void)
{
UINT8 bTemp;
VP 110/01x 8-9
Additional Local I/O Functions