HAL IWDG Overview ¶
Introducing IWDG ¶
- group IWDG_Introduction
-
The IWDG hardware abstraction layer provides a set of APIs to interface with the IWDG peripheral on STM32 microcontrollers.
The Independent Watchdog (IWDG) peripheral offers a high safety level thanks to its capability to detect malfunctions due to software or hardware failures.
The IWDG is clocked by an independent clock and stays active even if the main clock fails. In addition, the watchdog function runs in the VDD voltage domain, allowing the IWDG to remain functional even in low-power modes.
The IWDG is best suited for applications that require the watchdog to run as a fully independent process outside the main application, making it reliable for detecting unexpected behavior.
This abstraction layer guarantees portability and ease of use across different STM32 series.
Module and files ¶
The following diagram illustrates the IWDG module and its associated files.
Component diagram ¶
The following diagram illustrates the software components involved in the IWDG module. It shows the interactions between the user application, HAL drivers, low-level drivers, and the hardware components.
Configuration table ¶
The following table lists the configuration defines for the HAL IWDG module, specifying their locations, default values, and descriptions:
- group IWDG_Configuration_Table
-
¶
Configuration inside the IWDG driver: ¶
Config defines
Where
Default value
Note
USE_HAL_IWDG_MODULE
hal_conf.h
1
Enable the HAL IWDG module.
USE_HAL_IWDG_REGISTER_CALLBACKS
hal_conf.h
0
Enable register callback assertions.
USE_HAL_CHECK_PARAM
hal_conf.h
0
Enable checking of vital parameters at
runtime
USE_HAL_IWDG_HARDWARE_START
hal_conf.h
0
IWDG driver starts in HW mode
USE_HAL_IWDG_USER_DATA
hal_conf.h
0
Add user data in the HAL IWDG handle
USE_HAL_IWDG_TIME_UNIT (*)
hal_conf.h
HAL_IWDG_TIME_UNIT_MS
Time unit to be used for IWDG driver
USE_HAL_IWDG_LSI_FREQ (**)
hal_conf.h
LSI_VALUE
LSI value to be applied to the IWDG driver
USE_ASSERT_DBG_PARAM
PreProcessor env
NA
Enable parameter assertions.
USE_ASSERT_DBG_STATE
PreProcessor env
NA
Enable state assertions.
(*) Select the value of the time unit with the USE_HAL_IWDG_TIME_UNIT define:
HAL_IWDG_TIME_UNIT_US: IWDG driver time unit in microseconds.
HAL_IWDG_TIME_UNIT_MS: IWDG driver time unit in milliseconds.
HAL_IWDG_TIME_UNIT_S: IWDG driver time unit in seconds.
The default time unit is milliseconds if not set by the user.
(**) Select the value of the LSI frequency with the USE_HAL_IWDG_LSI_FREQ define:
LSI_VALUE_DYNAMIC: Dynamic LSI to be computed and set by the user.
LSI_VALUE: LSI value of 32kHz. The default LSI value is LSI_VALUE if not set by the user.
¶
Allowed maximum time ranges: ¶
The selection of prescaler is done as follows: as long as the requested reset time value is lower than the max_time of a time range n, the algorithm keeps the same prescaler n. Once it exceeds the max_time of the range n, the algorithm switches to the prescaler of the range n+1. The following table describes the possible maximum time ranges for each prescaler and with both standard values of the LSI frequency:
Note:
For “Not supported” values in s, switch to the ms or us unit. Similarly, for “Not supported” values in us, switch to the ms or s unit.
To cover all ranges, time unit static configuration has been introduced and can be expressed in us, ms, or seconds.
LSI(Hz)
Prescaler
Step(us)
Max(us)
Max(ms)
Max(s)
32000
4
125
512000
512
Not supported
32000
8
250
1024000
1024
1.024
32000
16
500
2048000
2048
2.048
32000
32
1000
4096000
4096
4.096
32000
64
2000
8192000
8192
8.192
32000
128
4000
16384000
16384
16.384
32000
256
8000
32768000
32768
32.768
32000
512
16000
65536000
65536
65.536
32000
1024
32000
131072000
131072
131.072