Skip to main content
Graduate II
September 3, 2023
Question

Implementing IWDG in sleep mode

  • September 3, 2023
  • 3 replies
  • 3024 views

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.

    This topic has been closed for replies.

    3 replies

    Graduate
    September 3, 2023

    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.

    Nico3Author
    Graduate II
    September 3, 2023

    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.

     

     

     

    ST Employee
    September 5, 2023

    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!

     

     

    Graduate II
    September 3, 2023

    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

    Graduate II
    September 5, 2023
    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?

    Graduate II
    September 6, 2023

    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?