MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
WDT: Watchdog Timer Driver

Overview

Peripheral features and how this peripheral works

The Watchdog Timer (WDT) regains control in case of system failure (due to a software error) to increase application reliability. The WDT can generate a reset or an interrupt when the counter reaches a given timeout value.

Features

How this peripheral works

  1. Configure the WDT features properly, enable WDT
  2. Service periodically to prevent reset event

How this driver is designed to make this peripheral works.

The wdt driver provides a structure wdt_config_t which contains all the programmable features of WDT. The WDT_Init() function takes the argument of structure pointer to wdt_config_t and configures the WDT features, then enable WDT. For the most simple user scenarios, only need to provide WDT service function to feed the WDT timer to avoid reset. But considering user may have some enhanced situation which needs to re-configure the features, such as to re-install timeout value, enable/disable interrupt functionality of WDT, several function groups are designed as below:

How to use this driver

Data Structures

struct  wdt_config_t
 structure for WDT module initialization configuration. More...
 

Enumerations

enum  wdt_timeout_response_mode_t {
  kWDT_ModeTimeoutReset = 0,
  kWDT_ModeTimeoutInterrupt = 1
}
 enumeration for wdt timeout response mode select. More...
 
enum  wdt_reset_width_t {
  kWDT_ResetPulseLen2 = 0,
  kWDT_ResetPulseLen4 = 1,
  kWDT_ResetPulseLen8 = 2,
  kWDT_ResetPulseLen16 = 3,
  kWDT_ResetPulseLen32 = 4,
  kWDT_ResetPulseLen64 = 5,
  kWDT_ResetPulseLen128 = 6,
  kWDT_ResetPulseLen256 = 7
}
 enumeration for wdt reset assert width select. More...
 
enum  wdt_timeout_value_t {
  kWDT_TimeoutVal2ToThePowerOf16 = 0,
  kWDT_TimeoutVal2ToThePowerOf17 = 1,
  kWDT_TimeoutVal2ToThePowerOf18 = 2,
  kWDT_TimeoutVal2ToThePowerOf19 = 3,
  kWDT_TimeoutVal2ToThePowerOf20 = 4,
  kWDT_TimeoutVal2ToThePowerOf21 = 5,
  kWDT_TimeoutVal2ToThePowerOf22 = 6,
  kWDT_TimeoutVal2ToThePowerOf23 = 7,
  kWDT_TimeoutVal2ToThePowerOf24 = 8,
  kWDT_TimeoutVal2ToThePowerOf25 = 9,
  kWDT_TimeoutVal2ToThePowerOf26 = 10,
  kWDT_TimeoutVal2ToThePowerOf27 = 11,
  kWDT_TimeoutVal2ToThePowerOf28 = 12,
  kWDT_TimeoutVal2ToThePowerOf29 = 13,
  kWDT_TimeoutVal2ToThePowerOf30 = 14,
  kWDT_TimeoutVal2ToThePowerOf31 = 15
}
 enumeration for wdt timeout value config. More...
 

Driver version

#define FSL_WDT_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 WDT driver version 2.0.0. More...
 

WDT refresh pattern.

#define WDT_REFRESH_PATTERN   (0x76U)
 Refresh pattern to restart WDT.
 

Initialization Interfaces

void WDT_Init (WDT_Type *base, const wdt_config_t *config)
 Initializes the WDT module with input configuration Call this function to do initialization configuration for WDT module. More...
 
void WDT_GetDefaultConfig (wdt_config_t *config)
 Prepares an available pre-defined setting for module's configuration. More...
 

WDT Operation Interfaces

static void WDT_Enable (WDT_Type *base, bool enable)
 Enable/Disable the WDT module. More...
 
static void WDT_SetTimeoutValue (WDT_Type *base, wdt_timeout_value_t timeoutValue)
 Sets the WDT timeout value.
 
static uint32_t WDT_GetCounterValue (WDT_Type *base)
 Gets the WDT timeout value.
 
void WDT_Refresh (WDT_Type *base)
 Refreshes the WDT timer. More...
 

Interrupt Control Interfaces

static void WDT_EnableInterrupt (WDT_Type *base)
 Enables the WDT interrupt, if config->timeoutMode = kWDT_TimeoutModeInterrupt for calling WDT_Init, the WDT interrupt is by default enabled, this function does not take effect. More...
 
static void WDT_DisableInterrupt (WDT_Type *base)
 Enables the WDT interrupt, if config->timeoutMode = kWDT_TimeoutModeReset for calling WDT_Init, the WDT interrupt is by default disabled, this function does not take effect. More...
 

Status get/clear interface.

static bool WDT_GetInterruptStatus (WDT_Type *base)
 Gets WDT interrupt status. More...
 
static void WDT_ClearInterruptStatus (WDT_Type *base)
 Clear WDT interrupt status. More...
 

Data Structure Documentation

struct wdt_config_t

Macro Definition Documentation

#define FSL_WDT_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))

Enumeration Type Documentation

Enumerator
kWDT_ModeTimeoutReset 

WDT will generate system reset for timeout.

kWDT_ModeTimeoutInterrupt 

WDT will generate interrupt for timeout.

Enumerator
kWDT_ResetPulseLen2 

WDT reset pulse length: 2 pclk cycles.

kWDT_ResetPulseLen4 

WDT reset pulse length: 4 pclk cycles.

kWDT_ResetPulseLen8 

WDT reset pulse length: 8 pclk cycles.

kWDT_ResetPulseLen16 

WDT reset pulse length: 16 pclk cycles.

kWDT_ResetPulseLen32 

WDT reset pulse length: 32 pclk cycles.

kWDT_ResetPulseLen64 

WDT reset pulse length: 64 pclk cycles.

kWDT_ResetPulseLen128 

WDT reset pulse length: 128 pclk cycles.

kWDT_ResetPulseLen256 

WDT reset pulse length: 256 pclk cycles.

Enumerator
kWDT_TimeoutVal2ToThePowerOf16 

WDT timeout value : 2^16 pclk cycles.

kWDT_TimeoutVal2ToThePowerOf17 

WDT timeout value : 2^17 pclk cycles.

kWDT_TimeoutVal2ToThePowerOf18 

WDT timeout value : 2^18 pclk cycles.

kWDT_TimeoutVal2ToThePowerOf19 

WDT timeout value : 2^19 pclk cycles.

kWDT_TimeoutVal2ToThePowerOf20 

WDT timeout value : 2^20 pclk cycles.

kWDT_TimeoutVal2ToThePowerOf21 

WDT timeout value : 2^21 pclk cycles.

kWDT_TimeoutVal2ToThePowerOf22 

WDT timeout value : 2^22 pclk cycles.

kWDT_TimeoutVal2ToThePowerOf23 

WDT timeout value : 2^23 pclk cycles.

kWDT_TimeoutVal2ToThePowerOf24 

WDT timeout value : 2^24 pclk cycles.

kWDT_TimeoutVal2ToThePowerOf25 

WDT timeout value : 2^25 pclk cycles.

kWDT_TimeoutVal2ToThePowerOf26 

WDT timeout value : 2^26 pclk cycles.

kWDT_TimeoutVal2ToThePowerOf27 

WDT timeout value : 2^27 pclk cycles.

kWDT_TimeoutVal2ToThePowerOf28 

WDT timeout value : 2^28 pclk cycles.

kWDT_TimeoutVal2ToThePowerOf29 

WDT timeout value : 2^29 pclk cycles.

kWDT_TimeoutVal2ToThePowerOf30 

WDT timeout value : 2^30 pclk cycles.

kWDT_TimeoutVal2ToThePowerOf31 

WDT timeout value : 2^31 pclk cycles.

Function Documentation

void WDT_Init ( WDT_Type *  base,
const wdt_config_t config 
)

The configurations are:

  • WDT counter timeout value
  • Timeout response mode select
  • Reset assert pulse width configuration
  • WDT enable/disable
    Parameters
    baseWDT peripheral base address.
    configThe pointer to WDT configuration structure, wdt_config_t.
void WDT_GetDefaultConfig ( wdt_config_t config)

This function initializes the WDT configuration structure to default values. config->timeoutValue = kWDT_TimeoutVal2ToThePowerOf16; config->timeoutMode =kWDT_TimeoutModeReset; config->resetWidth = kWDT_ResetWidthLen2; config->enableWDT = false;

Parameters
configPointer to the WDT configuration structure, wdt_config_t.
static void WDT_Enable ( WDT_Type *  base,
bool  enable 
)
inlinestatic

This function enable/disables the WDT. To disable the WDT Watchdog, call WDT_Enable(base, false).

Parameters
baseWDT peripheral base address.
enableEnable the feature or not.
void WDT_Refresh ( WDT_Type *  base)

This function feeds/services the WDT.

Parameters
baseWDT peripheral base address.
static void WDT_EnableInterrupt ( WDT_Type *  base)
inlinestatic

This function set WDT timeout response mode to generate interrupt.

Parameters
baseWDT peripheral base address
static void WDT_DisableInterrupt ( WDT_Type *  base)
inlinestatic

This function set WDT timeout response mode to generate reset.

Parameters
baseWDT peripheral base address
static bool WDT_GetInterruptStatus ( WDT_Type *  base)
inlinestatic
Parameters
baseWDT peripheral base address
Returns
true if interrupt flag is asserted, else false
static void WDT_ClearInterruptStatus ( WDT_Type *  base)
inlinestatic
Parameters
baseWDT peripheral base address