cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 - make watchdog IWDG faster if it is already active?

awiernie
Senior II

I want to use the IWDG watchdog with the maximum possible time delay of approx. 30 seconds. As the device cannot be switched off, It has to go into standby mode (HAL_PWR_EnterSTANDBYMode) instead.  The issue here is, that the watchdog would wake it up after 30 seconds. Therefore I want to make the IWDG faster just before going into the sleep mode in order that it comes up again and then going into sleep mode a second time but without setting the IWDG.

My Question: Can the IWDG be triggered immediately or make it expire faster if it is already running?

1 ACCEPTED SOLUTION

Accepted Solutions
Danish1
Lead II

I imagine HAL calls for this are not provided by ST - it's too rare a request for them to write code.

I don't see which stm32f4 you mean. Looking at the Reference Manual for stm32f405/415, I think that you can update IWDG->PR provided you first write 0x5555 to IWDG->KR. This can push the prescaler to (e.g.) /4 rather than /256. Is that good enough? 

View solution in original post

6 REPLIES 6
Sarra.S
ST Employee

Hello @awiernie 

I assume you're using PSC divider =256 and RL= 4095 to have a timeout of 32,768 seconds as per the reference manual.

However, These timings are given for a 32 kHz clock but the microcontroller's internal RC frequency can vary.

Please refer to the LSI oscillator characteristics table in your product datasheet for max and min values. 

>>Can the IWDG be triggered immediately or make it expire faster if it is already running?

 One workaround is to minimize the RL value so you can theoretically have a timeout of less than 30s and with the LSI tolerance it can reach 30s 

Another thing, before using the IWDG, LSI can be measured- with TIM5, and the IWDG is then started with a corrected value. This can also improve the tolerance of the timing, there is an example covering this in STM32F4 Cube package - IWDG example

 

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hello @Sarra.S,

maybe you have misunderstood my question. I need the IWDG with the longer timeout. However, as it is not possible to deactivate the IWDG if it was started once, I want to shorten the time just before sending the MCU into standby, because it will wake up by the IWDG. And I don't wont that the wakeup followed by standby takes 30 seconds after the user has pressed the "off" button. It seems to me, that it is not possible to let the watchdog trigger earlier than it was initialised? Why not, it would be a safe option.

Danish1
Lead II

I imagine HAL calls for this are not provided by ST - it's too rare a request for them to write code.

I don't see which stm32f4 you mean. Looking at the Reference Manual for stm32f405/415, I think that you can update IWDG->PR provided you first write 0x5555 to IWDG->KR. This can push the prescaler to (e.g.) /4 rather than /256. Is that good enough? 

It is a STM32F479. It will try.

Yes it works, which is exactly the same as the function HAL_IWDG_Init already makes. Now, I just call HAL_IWDG_Init with the new Init parameters. 

Piranha
Chief II

C'mon... just do the software reset. After that detect the reset reason, do not initialize the IWDG and put the MCU in Standby mode. If detecting the reset reason is not enough, implement a special variable, which keeps the state during reset like it's done for bootloaders.