1.25.25 Watchdog Timer (WDT)

The Watchdog Timer (WDT) is used to prevent system lockup if the software becomes trapped in a deadlock. It features one 12-bit down counter that allows a watchdog period of up to 16 seconds (slow clock around 32 kHz).

The WDT can generate a general reset or a processor reset only. In addition, it can be stopped while the processor is in Debug mode or Sleep mode (Idle mode).

Using The Library

The WDT is used to prevent system lockup if the software becomes trapped in a deadlock. It is supplied with VDDCORE. It restarts with initial values on processor reset.

The WDT is built around a 12-bit down counter loaded with the value defined in field PERIOD of the Window Level Register (WDT_WLR). WDT uses slow clock divided by 128 to establish the maximum watchdog period to 16 seconds (with a typical slow clock of 32.768 kHz).

Here is an example code to enable watchdog timer and keep clearing at regular intervals

WDT_Enable();

while ( true )
{
    // Application Code

    WDT_Clear();
}

Library Interface

Watchdog Timer peripheral library provides the following interfaces:

Functions

Name Description
WDT_Initialize Initializes given instance of the WDT peripheral
WDT_Clear Restart the WDT counter
WDT_Enable Enable the WDT counter
WDT_Disable Disable the WDT counter
WDT_CallbackRegister Sets the pointer to the function (and it's context) to be called when the Timeout events occur

Data types and constants

Name Type Description
WDT_CALLBACK Typedef Defines the data type and function signature for the WDT peripheral callback function