This application note explains how to use the WDT in the FreeRTOS demo application.
1. Understanding FreeRTOS WDT Interfaces
1.1. FreeRTOS WDI Implementation
The FreeRTOS BSP make uses of the STM32CubeH7 software component to provide a device driver for the STM32H7 WDT. The driver is configured (enabled / disabled) at the BSP build time, using the HAL_IWDG_MODULE_ENABLED
configuration option, defined in the stm32h7xx_hal_conf.h
file.
1.2. FreeRTOS WDT C-Binding API
The WDT driver implements the following C-binding API:
Function | Description | Comments |
| ||
Initialize the WDT according to the parameters specified by |
| |
| ||
Refresh the WDT | Returns one of |
The IWDG_HandleTypeDef data structure used in the HAL_IWDG_Init
interface has the following definition:
typedef struct { IWDG_TypeDef * Instance; /* Register base address */ IWDG_InitTypeDef Init; /* IWDG required parameters */ } IWDG_HandleTypeDef;
The IWDG_InitTypeDef data structure used in IWDG_HandleTypeDef has the following definition:
typedef struct { uint32_t Prescaler; /* Select the prescaler of the IWDG. */ uint32_t Reload; /* Specifies the IWDG down-counter reload value. */ uint32_t Window; /* Specifies the window value to be compared to the down-counter. */ } IWDG_InitTypeDef;
1.3. FreeRTOS WDT Strobing Task
The FreeRTOS tdemo
application implements a separate thread (called the "WDT thread"), whose only task will be to strobe the WDT periodically, to ensure that the WDT does not reset the system.
The WDT will be enabled at the start of the WDT thread, before it enters the endless WDT strobing loop.
The WDT period will be set to 2 seconds.
2. WDT CLI Command
The FreeRTOS application implements the following WDT related CLI command:
Command | Description | Comments |
| Command the WDT thread to stop the WDT strobing (which will result in resetting the system on WDT expiration) |
3. Validating WDT Operation
Use the following step-wise procedure to validate the FreeRTOS WDT operation:
Power cycle the target board and let it boot to the FreeRTOS CLI.
Let the board sit idle for 5 minutes, validate that no reset occurs.
From the CLI, stop the WDT strobing:
CLI> wdt_stop
Validate that the board resets within several seconds:
CLI> U-Boot SPL 2019.04-emcraft-h7-2.0.0-g5445b38714 (Apr 19 2023 - 14:03:32 +0400) ... U-Boot 2019.04-emcraft-h7-2.0.0-g5445b38714 (Apr 19 2023 - 14:03:32 +0400) ... STM32H7-SOM U-Boot >