2023-06-08 07:11 AM
HAL_IWDG_Init is implemented in file stm32L4xx_hal. Here two statement from the L476 documentation:
a) "When the independent watchdog is started by writing the value 0x0000 CCCC in the IWDG key register (IWDG_KR), the counter starts counting down from the reset value of 0xFFF. When it reaches the end ..."
b) "As soon as the window value is changed, a reload operation is performed in order to reset the downcounter to the IWDG reload register (IWDG_RLR) value ..."
Now my issue: I don't want to use the window feature. Therefore i pass 4095 to the init function. This should - according tho the docu - not influence the counter because the window value isn't change in the register. However, the implementation in the iwdg-hal-file triggers explicitly a reload even if the window value is NOT changed:
if (hiwdg->Instance->WINR != hiwdg->Init.Window)
{ ... the window change case ... not relevant for this discussion }
else {
/* Reload IWDG counter with value defined in the reload register */
__HAL_IWDG_RELOAD_COUNTER(hiwdg); // <<-- line 224
}
what is the reason to perform a reload? Isn't it in constrast to the documentation? Are there other 'forces' making this approach necessary? Any chance to make it controllable by user? Without modification of generated code?
Background: CubeMX calls the init function quite early. Once everything is up and running i need a reload every 200 ms. But the startup phase takes ca. 1 second. I could benefit from the fact that the initial counter value is 4095 giving me more time until the first relaod happens. When the first reset happens in time the smaller reload value is loaded (for 200 ms) and all subsequent resets need to happen in shorter time periods.
Any comment on this? Thanks and Regards ... Matthias.
2023-06-09 09:43 AM - edited 2023-11-20 03:38 AM
> But the startup phase takes ca. 1 second. I could benefit from the fact that the initial counter value is 4095 giving me more time until the first relaod happens
I would think most users would want a reset within 200ms if that's what the reload value is. HAL isn't going to support every niche case.
IWDG is pretty easy to set up yourself, or at least to test to see if what you want is a possibility, but the procedure in the RM says to refresh. That's most likely why HAL does that.