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

Overview

The MCUXpresso SDK provides a peripheral driver for the Watchdog Timer module of MCUXpresso SDK devices.

Typical use case

Example use of WDT API. Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/wdt

Data Structures

struct  wdt_config_t
 Describes WDT configuration structure. More...
 

Enumerations

enum  _wdt_flags {
  kWDT_TimeoutFlag = WDT_WDMOD_TOF_MASK,
  kWDT_InterruptFlag = WDT_WDMOD_INT_MASK
}
 Describes WDT flags. More...
 

Driver version

#define FSL_WDT_DRIVER_VERSION   (MAKE_VERSION(2, 0, 1))
 Defines WDT driver version 2.0.1. More...
 

WDT Initialization and De-initialization

void WDT_GetDefaultConfig (wdt_config_t *config)
 Initializes the WDT configuration structure. More...
 
void WDT_Init (WDT_Type *base, const wdt_config_t *config)
 Initializes the WDT. More...
 
void WDT_Deinit (WDT_Type *base)
 Shuts down the WDT. More...
 

WDT Functional Operation

static void WDT_Enable (WDT_Type *base)
 Enables the WDT module. More...
 
static uint32_t WDT_GetStatusFlags (WDT_Type *base)
 Gets the WDT all status flags. More...
 
static void WDT_ClearStatusFlags (WDT_Type *base, uint32_t mask)
 Clears the WDT flag. More...
 
static void WDT_SetTimeoutCounter (WDT_Type *base, uint32_t timeoutCount)
 Sets the WDT timeout counter. More...
 
static void WDT_Feed (WDT_Type *base)
 Feed WDT timer. More...
 
static uint32_t WDT_GetCurrentCount (WDT_Type *base)
 Get the current value of WDT. More...
 

Data Structure Documentation

struct wdt_config_t

Data Fields

uint32_t timeoutCounter
 
Timeout counter for WDT, should be between 0xFF ~ 0x7FFFFF, indicates timeoutValue

between (TWDCLK * 256 * 4) and (TWDCLK * 224 * 4), TWDCLK = 1/WDT_CLK. More...

 
bool enableReset
 WDT reset enable, when enable, WDT timeout causes a chip reset. More...
 
bool enableWdog
 Enables or disables WDT. More...
 

Field Documentation

uint32_t wdt_config_t::timeoutCounter
bool wdt_config_t::enableReset
bool wdt_config_t::enableWdog

Macro Definition Documentation

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

Enumeration Type Documentation

enum _wdt_flags
Enumerator
kWDT_TimeoutFlag 

WDT timeout flag, set when WDT times out.

kWDT_InterruptFlag 

WDT interrupt flag, set in interrupt mode, indicates WDT interrupt due to WDT counter-underflow happens.

Function Documentation

void WDT_GetDefaultConfig ( wdt_config_t config)

This function initializes the WDT configuration structure to default values. The default values are as follows.

* wdtConfig->timeoutValue = 0xFFFFU;
* wdtConfig->enableReset = true;
* wdtConfig->enableWdog = true;
*
Parameters
configPointer to the WDT configuration structure.
See Also
wdt_config_t
void WDT_Init ( WDT_Type *  base,
const wdt_config_t config 
)

This function initializes the WDT. When called, the WDT runs according to the configuration.

This is an example.

* wdt_config_t config;
* config.timeoutValue = 0x7ffU;
* WDT_Init(wdt_base,&config);
*
Parameters
baseWDT peripheral base address
configThe configuration of WDT
void WDT_Deinit ( WDT_Type *  base)

This function shuts down the WDT.

static void WDT_Enable ( WDT_Type *  base)
inlinestatic
Parameters
baseWDT peripheral base address
static uint32_t WDT_GetStatusFlags ( WDT_Type *  base)
inlinestatic

This function gets all status flags.

This is an example for getting the Running Flag.

* uint32_t status;
* status = WDT_GetStatusFlags (wdt_base) & kWDT_TimeoutFlag;
*
Parameters
baseWDT peripheral base address
Returns
State of the status flag: asserted (true) or not-asserted (false).
See Also
_wdt_flags
  • true: a related status flag has been set.
  • false: a related status flag is not set.
static void WDT_ClearStatusFlags ( WDT_Type *  base,
uint32_t  mask 
)
inlinestatic

This function clears the WDT status flag.

This is an example for clearing the timeout (interrupt) flag.

Parameters
baseWDT peripheral base address
maskThe status flags to clear, only support clear kWDT_TimeoutFlag.
static void WDT_SetTimeoutCounter ( WDT_Type *  base,
uint32_t  timeoutCount 
)
inlinestatic

This function sets the timeout counter. The timeoutCount should be between 0xFF ~ 0x7FFFFF, writing values below 0xFF cause 0x0000 00FF to be loaded to the WDT timer counter. The minimum timeoutValue is (TWDCLK * 256 * 4) and the maximum value is (TWDCLK * 224 * 4), TWDCLK = 1/WDT_CLK.

Parameters
baseWDT peripheral base address
timeoutCountWDT timeout counter; count of WDT clock tick.
static void WDT_Feed ( WDT_Type *  base)
inlinestatic

This is a mandatory step, if this function isn't called after enabling the WDT, WDT will ignore timeout errors and will not generate a WDT interrupt or reset the chip.

Parameters
baseWDT peripheral base address
static uint32_t WDT_GetCurrentCount ( WDT_Type *  base)
inlinestatic

The value reported by this function is older than the actual one. Retrieving this value takes up to 6 watchdog clock cycles + 6 system clock cycles due to the lock and synchronization procedure.

Parameters
baseWDT peripheral base address
Returns
Current value of WDT