WDT Driver

This Watchdog Timer (WDT) driver provides an interface to prevent system lock-up if the software becomes trapped in a deadlock. It is a system function for monitoring correct operation.

WDT makes it possible to recover from error situations such as runway or deadlocked code. The WDT is configured to a predefined timeout period, and is constantly running when enabled. If the WDT is not reset within the timeout period, it will issue a system reset.

Summary of the API's Functional Features

The API provides functions to:
  • Initialize and deinitialize the driver and associated hardware

  • Enable or disable WDT

  • Reset the watchdog (wdt_feed)

  • Timeout period set/get

Summary of Configuration Options

The main WDT parameters can be configured in START. Many of these parameters are used by the wdt_init function when initializing the driver and underlying hardware. Most of the initial values can be overridden and changed runtime by calling the appropriate API functions.

Driver Implementation Description

Limitations

Available timeout period is device specific, the user must refer the corresponding device to set the timeout period.

Timeout period can not be changed when WDT is enabled.

Example of Usage

The following shows a simple example of using the WDT. The WDT driver must have been initialized by wdt_init. This initialization will configure the operation of the hardware WDT instance.

The example sets the timeout period, and then enables the WDT. When running the project on the board, the system restarts at regular intervals.

          /**
           * Example of using WDT_0.
           */
          void WDT_0_example(void)
          {
              uint32_t clk_rate;
              uint16_t timeout_period;
              clk_rate       = 1000;
              timeout_period = 4096;
              wdt_set_timeout_period(&WDT_0, clk_rate, timeout_period);
              wdt_enable(&WDT_0);
          }
        

Dependencies

  • WDT peripheral and clocks