Skip to main content
Associate
September 3, 2026
Question

CubeMX2: IWDG time unit selection does not change USE_HAL_IWDG_TIME_UNIT value

  • September 3, 2026
  • 0 replies
  • 10 views

In STM32CubeMX2 1.1.1, for the STM32C542RC MCU, enable the IWDG.
In “Applicative services”, enable “Start function generation”. In the subfolder “Calculator”, you have the possibility to change the “Time unit”. Set it to “Seconds”. The only change is the unit used in comments, e.g.:
 

/*
Start the Independent Watchdog (IWDG) with the following parameters:
- Maximum time before watchdog reset : 132 seconds
- Minimum time before refresh (window) : 0 seconds
- Early Wakeup Interrupt (EWI) time : 0 seconds
*/
hal_status_t mx_iwdg_start(void)
{
return HAL_IWDG_Start(&hIWDG, 0UL, 132UL, 0UL);
}

The arguments given to HAL_IWDG_Start() are not updated by this unit change. So the configuration of the time unit in this window is useless and does not touch any part of actual code. This is a problem and should be fixed.

For the unit change to effectively take effect, it is currently done in “Project settings” → “HAL common definitions” → “HAL IWDG” → “Use HAL IWDG time unit”. We can now select the time unit, that will define the variable USE_HAL_IWDG_TIME_UNIT in stm32c5xx_hal_conf.h.