cancel
Showing results for 
Search instead for 
Did you mean: 

Implementing IWDG in sleep mode

Nico3
Senior

I implemented IWDG  reset having counter of  12 second and am  refreshing it using HAL_IWDG_Refresh(&hiwdg) in while loop. 

Everything is working as expected. But now the issue is when I implement sleep mode. 

The processor will be in sleep and wakeup by interrupt. So if processor doesn't wakeup within 12 second then HAL_IWDG_Refresh will not be executed.

8 REPLIES 8
Danish1
Lead II

What do you want to happen?

How might you distinguish between stuck crashed asleep and operating correctly asleep?

One approach would be to have a periodic wakeup driven by a timer or the RTC, when you do a quick health-check and if things are good then refresh the watchdog.

Another approach would be to stop the watchdog from running, but for that you need to go through a reset cycle. So your startup-from-reset code would have to distinguish between intentional-reset-to-stop-watchdog-prior-to-sleep and reset-to-start/operate-normally.

Issamos
Lead II

Hello @Nico3 

I think that you should use a timer to interrupt every 12s and add the HAL_IWDG_Refresh function to the TIMER interrupt function to make sure that the command is executed directly after the wake-up from sleep mode using the TIMER interruption.

Hope this is helpful. If your question is answered please check this answer as best answer to be diffused.

Best regards.

II

Dear Danish, 

I would prefer to implement first option. 

"One approach would be to have a periodic wakeup driven by a timer or the RTC, when you do a quick health-check and if things are good then refresh the watchdog"

Please suggest how to do quick health check as you suggested.

 

 

 

Hello @Nico3

As @Danish1, using an RTC to wake up the MCU is a simple approach to consider! 

This Community article could be a good starting point!

 

 

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.

Piranha
Chief II
  1. Broken general low-power mode code.
  2. Broken Stop mode code.
  3. Broken RTC wake-up.

The code in knowledge base article you linked has all of those flaws. Does ST think it is OK to present everywhere a completely broken code, ignore almost all of the bug reports and pretend all of those issues do not exist?

I didn't create this topic, apparently @KDJEM.1 did. It was a post there:

https://community.st.com/t5/stm32-mcus-embedded-software/implementing-iwdg-in-sleep-mode/m-p/587178

In addition I don't think this should be a separate topic, because all of the issues already are reported in the three linked topics. Also the title "Re: Implementing IWDG in sleep mode" is now not appropriate and, of course, it is pre-pended with the useless/harmful e-mail style "Re: " stupidity.

@Lina_DABASINSKAITE , what is going on here?

Hello @Piranha ,

Sorry for the wrong action on my side. I will move back this thread to the original discussion.

Please note that the mentioned questions are under investigation to tack a relevant actions.

Thank you.

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.

Please note that the mentioned questions are under investigation to tack a relevant actions.


You mean like this documentation issue? In 4 years ST still has not been able of even fixing a few sentences in documentation. Not even a code!

Or you mean like this severe bug? The fix is trivial, I even gave an example and it takes just a few minutes to implement it. Instead ST appointed some incompetent fool to it, who just blurted out a complete nonsense and dismissed the issue altogether.

And do I have to remind that all of the code created by HAL/Cube team is full of hundreds of bugs, which have not been fixed for years and are still ignored? Some 80% of reports are ignored completely, 10% are reported internally, 5% are tried to fix and about 1% are actually fixed... years later! The same is true for examples. And even the knowledge base articles, which present a code examples, present a broken code!