Skip to main content
RCres.1
Associate III
Apr 27, 2020 10:21 AM UTC
Solved

Not understanding IWDG and HAL in STM32F7

Hi,

I am trying to get working IWDG using HAL_IWDG library and I am not able to refresh the watchdog before IWDG_Reset.

As is said in page 6: (https://www.st.com/content/ccc/resource/training/technical/product_training/group0/01/24/22/29/38/70/40/57/STM32WB-WDG_TIMERS-Independent-Watchdog-IWDG/files/STM32WB-WDG_TIMERS-Independent-Watchdog-IWDG.pdf/_jcr_content/translations/en.STM32WB-WDG_TIMERS-Independent-Watchdog-IWDG.pdf

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

This topic has been closed for replies.
TDK
TDKBest answer
Apr 27, 2020 10:29 PM UTC

> 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.

"If you feel a post has answered your question, please click ""Accept as Solution""."

4 replies

waclawek.jan
Super User
Apr 27, 2020 9:49 PM UTC

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

TDK
Apr 27, 2020 10:23 PM UTC

The problem is almost certainly that your main loop is not actually calling wdgReset.

"If you feel a post has answered your question, please click ""Accept as Solution""."
TDK
TDKBest answer
Apr 27, 2020 10:29 PM UTC

> 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.

"If you feel a post has answered your question, please click ""Accept as Solution""."
RCres.1
RCres.1Author
Associate III
Apr 29, 2020 6:27 AM UTC

Wow...this was a huge mistake.....Now is working

Thanks