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_int_cnt++;
}
else
{
while (1)
{
}
}
}
int main(void)
{
BOARD_InitHardware();
PRINTF("\r\nWatchdog example.\r\n");
{
PRINTF("Watchdog reset occurred\r\n");
}
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");
}
}
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.
|
|
void WDT_Init |
( |
WDT_Type * |
base, |
|
|
const wdt_config_t * |
config |
|
) |
| |
This function initializes the WDT.
- Parameters
-
base | WDT peripheral base address. |
config | pointer to configuration structure |
void WDT_Deinit |
( |
WDT_Type * |
base | ) |
|
This function shuts down the WDT.
- Parameters
-
base | WDT peripheral base address. |
static void WDT_Unlock |
( |
WDT_Type * |
base | ) |
|
|
inlinestatic |
This function unlock WDT access.
- Parameters
-
base | WDT peripheral base address. |
static void WDT_Lock |
( |
WDT_Type * |
base | ) |
|
|
inlinestatic |
This function unlock WDT access.
- Parameters
-
base | WDT peripheral base address. |
static void WDT_ClearStatusFlags |
( |
WDT_Type * |
base | ) |
|
|
inlinestatic |
This function clears WDT status flag.
- Parameters
-
base | WDT peripheral base address. |
This function initializes the WDT configure structure to default value. The default value are:
- Parameters
-
config | pointer 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
-
base | WDT peripheral base address. |
cycle | time-out interval |