The MCUXpresso SDK provides a peripheral driver for the Watchdog module (WDOG) of MCUXpresso SDK devices.
Function groups
Initialization and deinitialization
The function WWDT_Init() initializes the watchdog timer with specified configurations. The configurations include timeout value and whether to enable watchdog after init. The function WWDT_GetDefaultConfig() gets the default configurations.
The function WWDT_Deinit() disables the watchdog and the module clock.
Status
Provides functions to get and clear the WWDT status.
Interrupt
Provides functions to enable/disable WWDT interrupts and get current enabled interrupts.
Watch dog Refresh
The function WWDT_Refresh() feeds the WWDT.
Typical use case
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/wwdt
Data Fields |
bool | enableWwdt |
| Enables or disables WWDT.
|
|
bool | enableWatchdogReset |
| true: Watchdog timeout will cause a chip reset false: Watchdog timeout will not cause a chip reset
|
|
bool | enableWatchdogProtect |
| true: Enable watchdog protect i.e timeout value can only be changed after counter is below warning & window values false: Disable watchdog protect; timeout value can be changed at any time
|
|
bool | enableLockOscillator |
| true: Disabling or powering down the watchdog oscillator is prevented Once set, this bit can only be cleared by a reset false: Do not lock oscillator
|
|
uint32_t | windowValue |
| Window value, set this to 0xFFFFFF if windowing is not in effect.
|
|
uint32_t | timeoutValue |
| Timeout value.
|
|
uint32_t | warningValue |
| Watchdog time counter value that will generate a warning interrupt. More...
|
|
uint32_t | clockFreq_Hz |
| Watchdog clock source frequency. More...
|
|
uint32_t wwdt_config_t::warningValue |
Set this to 0 for no warning
uint32_t wwdt_config_t::clockFreq_Hz |
This structure contains the WWDT status flags for use in the WWDT functions.
Enumerator |
---|
kWWDT_TimeoutFlag |
Time-out flag, set when the timer times out.
|
kWWDT_WarningFlag |
Warning interrupt flag, set when timer is below the value WDWARNINT.
|
This function initializes the WWDT configure structure to default value. The default value are:
* config->enableWwdt = true;
* config->enableWatchdogReset = false;
* config->enableWatchdogProtect = false;
* config->enableLockOscillator = false;
* config->windowValue = 0xFFFFFFU;
* config->timeoutValue = 0xFFFFFFU;
* config->warningValue = 0;
*
- Parameters
-
config | Pointer to WWDT config structure. |
- See Also
- wwdt_config_t
void WWDT_Init |
( |
WWDT_Type * |
base, |
|
|
const wwdt_config_t * |
config |
|
) |
| |
This function initializes the WWDT. When called, the WWDT runs according to the configuration.
Example:
- Parameters
-
base | WWDT peripheral base address |
config | The configuration of WWDT |
void WWDT_Deinit |
( |
WWDT_Type * |
base | ) |
|
This function shuts down the WWDT.
- Parameters
-
base | WWDT peripheral base address |
static void WWDT_Enable |
( |
WWDT_Type * |
base | ) |
|
|
inlinestatic |
This function write value into WWDT_MOD register to enable the WWDT, it is a write-once bit; once this bit is set to one and a watchdog feed is performed, the watchdog timer will run permanently.
- Parameters
-
base | WWDT peripheral base address |
static void WWDT_Disable |
( |
WWDT_Type * |
base | ) |
|
|
inlinestatic |
This function write value into WWDT_MOD register to disable the WWDT.
- Parameters
-
base | WWDT peripheral base address |
static uint32_t WWDT_GetStatusFlags |
( |
WWDT_Type * |
base | ) |
|
|
inlinestatic |
This function gets all status flags.
Example for getting Timeout Flag:
- Parameters
-
base | WWDT peripheral base address |
- Returns
- The status flags. This is the logical OR of members of the enumeration _wwdt_status_flags_t
void WWDT_ClearStatusFlags |
( |
WWDT_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
This function clears WWDT status flag.
Example for clearing warning flag:
- Parameters
-
base | WWDT peripheral base address |
mask | The status flags to clear. This is a logical OR of members of the enumeration _wwdt_status_flags_t |
static void WWDT_SetWarningValue |
( |
WWDT_Type * |
base, |
|
|
uint32_t |
warningValue |
|
) |
| |
|
inlinestatic |
The WDWARNINT register determines the watchdog timer counter value that will generate a watchdog interrupt. When the watchdog timer counter is no longer greater than the value defined by WARNINT, an interrupt will be generated after the subsequent WDCLK.
- Parameters
-
base | WWDT peripheral base address |
warningValue | WWDT warning value. |
static void WWDT_SetTimeoutValue |
( |
WWDT_Type * |
base, |
|
|
uint32_t |
timeoutCount |
|
) |
| |
|
inlinestatic |
This function sets the timeout value. Every time a feed sequence occurs the value in the TC register is loaded into the Watchdog timer. Writing a value below 0xFF will cause 0xFF to be loaded into the TC register. Thus the minimum time-out interval is TWDCLK*256*4. If enableWatchdogProtect flag is true in wwdt_config_t config structure, any attempt to change the timeout value before the watchdog counter is below the warning and window values will cause a watchdog reset and set the WDTOF flag.
- Parameters
-
base | WWDT peripheral base address |
timeoutCount | WWDT timeout value, count of WWDT clock tick. |
static void WWDT_SetWindowValue |
( |
WWDT_Type * |
base, |
|
|
uint32_t |
windowValue |
|
) |
| |
|
inlinestatic |
The WINDOW register determines the highest TV value allowed when a watchdog feed is performed. If a feed sequence occurs when timer value is greater than the value in WINDOW, a watchdog event will occur. To disable windowing, set windowValue to 0xFFFFFF (maximum possible timer value) so windowing is not in effect.
- Parameters
-
base | WWDT peripheral base address |
windowValue | WWDT window value. |
void WWDT_Refresh |
( |
WWDT_Type * |
base | ) |
|
This function feeds the WWDT. This function should be called before WWDT timer is in timeout. Otherwise, a reset is asserted.
- Parameters
-
base | WWDT peripheral base address |