[MCX A153] WWDT Beginner's Guide (Japanese Blog) This article explains the basic concepts of WWDT ( Windowed Watchdog Timer ) on the MCX A153 and how to use it with the MCUXpresso SDK, aimed at engineers who are new to NXP products. First, we will explain the hardware overview, and then we will explain how to use the MCUXpresso SDK using the FRDM-MCXA153 board as a basis, along with code snippets.
(Reading time: 20 minutes)
1. WWDT Module Overview
1.1 Features of WWDT
WWDT (Windowed Watchdog Timer) is a hardware monitoring timer for detecting software malfunctions and unexpected hang-ups.
In addition to the standard Watchdog Timer functionality, WWDT can detect both "refreshing too early" and "refreshing too late." More details will follow.
The main features are as follows:
Windows-style timeout monitoring
Warning function before reset
Interrupt or reset generation
2. Basic operation of WWDT
2.1 The Role of WWDT
WWDT is a monitoring circuit that periodically verifies that the application is functioning correctly.
If the timer is not refreshed at the timing expected under normal operation, it is possible to generate an interrupt or reset the chip.
2.2 What is the Window System?
The Windows method is a feature that can detect not only "refreshes that are too slow" but also "refreshes that are too early." This means that even if an interrupt loop occurs that refreshes the timer, for example, it can detect the abnormality.
3. Basic Flow of SDK Drivers
To use WWDT, the following settings may be required depending on the software.
Interrupt handler definition
WWDT module initialization and execution
Refresh timer
This section demonstrates how to use the driver, using the MCUXpresso SDK sample project as an example.
Reference URL:
Hardware requirements — MCUXpresso SDK Documentation
mcuxsdk-examples/driver_examples/wwdt/wwdt.c at main · nxp-mcuxpresso/mcuxsdk-examples
3.1 Interrupt Handler Definition
In WWDT, warnings and timeouts are handled by defining interrupt handlers. Note that in this sample, a reset occurs upon timeout, so this interrupt handler will not be called when a timeout occurs.
void WWDT0_IRQHandler(void)
{
uint32_t wdtStatus = WWDT_GetStatusFlags(WWDT);
APP_LED_TOGGLE;
/* The chip will reset before this happens */
if (wdtStatus & kWWDT_TimeoutFlag)
{
WWDT_ClearStatusFlags(WWDT, kWWDT_TimeoutFlag);
}
/* Handle warning interrupt */
if (wdtStatus & kWWDT_WarningFlag)
{
/* A watchdog feed didn't occur prior to warning timeout */
WWDT_ClearStatusFlags(WWDT, kWWDT_WarningFlag);
/* User code. User can do urgent case before timeout reset.
* IE. user can backup the ram data or ram log to flash.
* the period is set by config.warningValue, user need to
* check the period between warning interrupt and timeout.
*/
}
SDK_ISR_EXIT_BARRIER;
}
3.2 WWDT Initialization
In this example, the window is set to 2-4 seconds. Therefore, if you reset the timer before 2 seconds have elapsed, the reset will occur, and if you do not reset it before 4 seconds have elapsed, the reset will also occur.
#define WDT_CLK_FREQ CLOCK_GetWwdtClkFreq()
/* The WDT divides the input frequency into it by 4 */
wdtFreq = WDT_CLK_FREQ / 4;
WWDT_GetDefaultConfig(&config);
/*
* Set watchdog feed time constant to approximately 4s
* Set watchdog warning time to 512 ticks after feed time constant
* Set watchdog window time to 2s
*/
config.timeoutValue = wdtFreq * 4;
config.warningValue = 512;
config.windowValue = wdtFreq * 2;
/* Configure WWDT to reset on timeout */
config.enableWatchdogReset = true;
/* Setup watchdog clock frequency(Hz). */
config.clockFreq_Hz = WDT_CLK_FREQ;
WWDT_Init(WWDT, &config);
3.6 Timer Reset
This API notifies WWDT that the application is functioning correctly within the window period. By continuously executing this API periodically, we avoid resets caused by WWDT.
WWDT_Refresh(WWDT);
4. Supplement
4.1 Concept of Window Period
Tightening the window period improves anomaly detection capabilities, but it also tightens the time constraints on processing .
It's best to start by evaluating it in a wider window.
4.2 Feed Timing
The following timings are commonly used for feeding:
Periodic tasks
RTOS monitoring task
4.3 Checking the Reset Factor
The MCXA153 allows you to check for WWDT-induced resets from the reset cause register. The SDK sample also provides a macro for determining WWDT resets.
#define IS_WWDT_RESET (0 != (CMC->SRS & CMC_SRS_WWDT0_MASK))
4.4 Protection Features
Enabling Watchdog Protect prevents unintended configuration changes.
4.5 Debugging Precautions
WWDT may continue to run even when breakpoints are stopped. It is recommended to loosen the settings during development.
5. Common stumbling blocks
Below is a summary of common stumbling blocks for each item.
(1) Reset immediately
The window period may be too strict.
(2) Resetting while feeding
You may be feeding too early.
(3) No interruption
Please check both the NVIC and WWDT settings .
( 4 ) Reset during debugging
WWDT may have timed out while stopped at a breakpoint.
6. Summary
WWDT is a very important module for improving the reliability of the MCXA153.
Using the NXP SDK,
WWDT_GetDefaultConfig()
WWDT_Init()
WWDT_Refresh()
You can implement the basic functions in these three steps.
First, we recommend running the FRDM-MCXA153 SDK sample, and then gradually learning about window settings and interrupt functions.
=========================
We are currently unable to respond to comments left in the "Comment" section of this post. We apologize for the inconvenience, but when making an inquiry, please use the subject line " Technical Questions to NXP". - How to contact us Please refer to the "( Japanese blog) " section. (If you are already an NXP distributor or have a relationship with NXP, you may ask your representative directly.)
This article explains the basic concepts of WWDT ( Windowed Watchdog Timer ) on the MCX A153 and how to use it with the MCUXpresso SDK, aimed at engineers who are new to NXP products. First, we will explain the hardware overview, and then we will explain how to use the MCUXpresso SDK using the FRDM-MCXA153 board as a basis, along with code snippets.
(Reading time: 20 minutes) MCUXpresso MCUXpresso SDK MCX Japanese Blog
View full article