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 (WDT) module of MCUXpresso SDK devices.

Typical use case

Example use of WDT API.

void WDT_IRQHandler(void)
{
wdt_int_flag = 1;
if (wdt_int_cnt < 5)
{
WDT_ClearStatusFlags(DEMO_WDT_BASE);
wdt_int_cnt++;
}
else
{
/* Wait for watchdog reset */
while (1)
{
}
}
}
int main(void)
{
wdt_config_t config;
BOARD_InitHardware();
PRINTF("\r\nWatchdog example.\r\n");
/* Check Reset source(First time device power on Watch dog reset source will be set) */
{
PRINTF("Watchdog reset occurred\r\n");
}
/* Clear reset source */
config.enableWdtReset = true;
config.loadValue = WDT_CYCLE_NUM;
WDT_Init(DEMO_WDT_BASE, &config);
NVIC_EnableIRQ(WDT_IRQn);
while (1)
{
if (wdt_int_cnt < 5)
{
PRINTF("Wait for watchdog interrupt\r\n");
}
else
{
PRINTF(
"When next watchdog interrupt occurrs and the program will stay in the watchdog interrupt "
"handler.\r\n");
PRINTF("WDT will trigger watchdog reset after load_value(3s) * 2\r\n");
}
while (wdt_int_flag == 0)
{
}
wdt_int_flag = 0;
PRINTF("Watchdog interrupt occurred and interrupt is cleared in the watchdog interrupt handler\r\n");
}
}

Files

file  fsl_wdt.h
 

Data Structures

struct  wdt_config_t
 Describes WDT configuration structure. More...
 

Functions

void WDT_Init (WDT_Type *base, const wdt_config_t *config)
 Initializes the WDT with configuration. More...
 
void WDT_Deinit (WDT_Type *base)
 Disable the WDT peripheral. More...
 
static void WDT_Unlock (WDT_Type *base)
 Unlock WDT access. More...
 
static void WDT_Lock (WDT_Type *base)
 Lock WDT access. More...
 
static void WDT_ClearStatusFlags (WDT_Type *base)
 Clears status flags. More...
 
void WDT_GetDefaultConfig (wdt_config_t *config)
 Initializes WDT configure sturcture. More...
 
static void WDT_Refresh (WDT_Type *base, uint32_t cycle)
 Refresh WDT counter. More...
 

Driver version

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

Data Structure Documentation

struct wdt_config_t

Data Fields

bool enableWdtReset
 true: Watchdog timeout will cause a chip reset false: Watchdog timeout will not cause a chip reset
 
uint32_t loadValue
 Load value, default value is 0xFFFFFFFF.
 

Function Documentation

void WDT_Init ( WDT_Type *  base,
const wdt_config_t config 
)

This function initializes the WDT.

Parameters
baseWDT peripheral base address.
configpointer to configuration structure
void WDT_Deinit ( WDT_Type *  base)

This function shuts down the WDT.

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

This function unlock WDT access.

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

This function unlock WDT access.

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

This function clears WDT status flag.

Parameters
baseWDT peripheral base address.
void WDT_GetDefaultConfig ( wdt_config_t config)

This function initializes the WDT configure structure to default value. The default value are:

* config->enableWdtReset = true;
* config->loadValue = 0xffffffff;
*
Parameters
configpointer to WDT config structure
static void WDT_Refresh ( WDT_Type *  base,
uint32_t  cycle 
)
inlinestatic

This function feeds the WDT. This function should be called before WDT timer is in timeout.

Parameters
baseWDT peripheral base address.
cycletime-out interval