MCUXpresso SDK API Reference Manual  Rev 2.12.1
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
 WDT configuration structure. More...
 

Macros

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

Typedefs

typedef void(* wdg_callback_t )(void)
 Callback function when WDT interrupt happens.
 

Functions

void WDT_Init (TIMERS_Type *base, const wdt_config_t *config)
 Initialize the WDT. More...
 
void WDT_Deinit (TIMERS_Type *base)
 De-initialize the WDT. More...
 
void WDT_StartTimer (TIMERS_Type *base, uint32_t timeoutCount)
 start wdt timer. More...
 
void WDT_StopTimer (TIMERS_Type *base)
 stop wdt timer. More...
 
static void WDT_SetInterruptThreshold (TIMERS_Type *base, uint32_t threshold)
 Sets the WDT triggerthreshold. More...
 
static void WDT_SetTimeoutStatus (TIMERS_Type *base)
 This function force sets the timeout status flag, even when WDT counter does not reach threshold. More...
 
static void WDT_ClearTimeoutStatus (TIMERS_Type *base)
 Timer clear timeout status. More...
 
static bool WDT_GetTimeoutStatus (TIMERS_Type *base)
 WDT timeout status enable/disable. More...
 
static uint32_t WDT_GetRemainCount (TIMERS_Type *base)
 WDT get wdt remain count. More...
 
static void WDT_Feed (TIMERS_Type *base)
 Feed WDT timer. More...
 
void WDT_HandleIRQ (TIMERS_Type *base)
 WDT IRQ handler. More...
 

Data Structure Documentation

struct wdt_config_t

Data Fields

uint32_t timeoutCount
 Timeout value set to register WDOG_TIMEOUT. More...
 
uint32_t threshold
 Time threshold to trigger interrupt. More...
 
wdg_callback_t callback
 Callback when interrupt happens. More...
 

Field Documentation

uint32_t wdt_config_t::timeoutCount

The maximum timeoutCount is 0x000FFFFF.

uint32_t wdt_config_t::threshold
wdg_callback_t wdt_config_t::callback

Macro Definition Documentation

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

Function Documentation

void WDT_Init ( TIMERS_Type *  base,
const wdt_config_t config 
)

This function register the interrupt callback, set the interrupt counter threshold, and sets the timeout to start WDT.

Parameters
basewdt base pointer.
configThe configuration.
void WDT_Deinit ( TIMERS_Type *  base)

This function stops the WDT, clears the interrupt flags, and unregisters the callback.

Parameters
basewdt base pointer.
void WDT_StartTimer ( TIMERS_Type *  base,
uint32_t  timeoutCount 
)
Parameters
basewdt base pointer.
timeoutCountthe initial timeout count of the timer. The total timeout time is determined by (1 / timerCountingFreq_Hz) * timeoutCount.The maximum timeoutCount is 0x000FFFFF.
void WDT_StopTimer ( TIMERS_Type *  base)
Parameters
basetimer base pointer.
static void WDT_SetInterruptThreshold ( TIMERS_Type *  base,
uint32_t  threshold 
)
inlinestatic

The Watchdog timer includes a "timeout pre-emption" feature whereby the non-maskable interrupt output intreq_wdg_o is asserted high when the counter reaches the value specified in field WDOG_INT_THRESHOLD defined in register TIMERS_WDOG_TRIGGER_INT_REG.

Parameters
baseWDT peripheral base address
thresholdWDT triggerthreshold value.
static void WDT_SetTimeoutStatus ( TIMERS_Type *  base)
inlinestatic
Parameters
basetimer base pointer.
static void WDT_ClearTimeoutStatus ( TIMERS_Type *  base)
inlinestatic
Parameters
basetimer base pointer.
timerthe specific timer to be stop.
static bool WDT_GetTimeoutStatus ( TIMERS_Type *  base)
inlinestatic
Parameters
basetimer base pointer.
Return values
trueis the timer timeout, false is the timeout still not timeout.
static uint32_t WDT_GetRemainCount ( TIMERS_Type *  base)
inlinestatic
Parameters
basetimer base pointer.
static void WDT_Feed ( TIMERS_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
void WDT_HandleIRQ ( TIMERS_Type *  base)

Call this function in the ISR.

Parameters
baseWDT peripheral base address