2020-04-27 03:21 AM
Hi,
I am trying to get working IWDG using HAL_IWDG library and I am not able to refresh the watchdog before IWDG_Reset.
I must refresh watchdog when RL < WINR
Watchdog timeout is set to 10s. wdgReset() is called from main loop, which I know is not consuming 10s.
MCU has a reset every 10s as a consequence
IWDG_HandleTypeDef t_wdg;
void wdgInit(void){
t_wdg.Instance = IWDG;
t_wdg.Init.Prescaler = IWDG_PRESCALER_256;
t_wdg.Init.Reload = 1250;
t_wdg.Init.Window = 1250;
HAL_IWDG_Init(&t_wdg);
}
void wdgReset(void){
if(t_wdg.Instance->RLR < t_wdg.Init.Window){
HAL_IWDG_Refresh(&t_wdg);
}
}
What I am missing?
Kind Regards,
Rafa
Solved! Go to Solution.
2020-04-27 03:29 PM
> t_wdg.Init.Reload = 1250;
Okay so RLR = 1250.
> t_wdg.Init.Window = 1250;
Okay, Window is also 1250.
> if(t_wdg.Instance->RLR < t_wdg.Init.Window){
How will this ever execute? You're not really using the window functionality. Just get rid of it and this check and call HAL_IWDG_Refresh unconditionally.
2020-04-27 02:49 PM
Check, if the refresh executes at all (e.g. toggle a pin next to it and observe that pin using oscilloscope or LA).
Try refreshing it unconditionally.
JW
2020-04-27 03:23 PM
The problem is almost certainly that your main loop is not actually calling wdgReset.
2020-04-27 03:29 PM
> t_wdg.Init.Reload = 1250;
Okay so RLR = 1250.
> t_wdg.Init.Window = 1250;
Okay, Window is also 1250.
> if(t_wdg.Instance->RLR < t_wdg.Init.Window){
How will this ever execute? You're not really using the window functionality. Just get rid of it and this check and call HAL_IWDG_Refresh unconditionally.
2020-04-28 11:27 PM
Wow...this was a huge mistake.....Now is working
Thanks