cancel
Showing results for 
Search instead for 
Did you mean: 

Not understanding IWDG and HAL in STM32F7

RCres.1
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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

View solution in original post

4 REPLIES 4

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
Guru

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
Guru

> 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
Associate III

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

Thanks