Skip to main content
Graduate II
March 5, 2025
Question

Clear Interrupts Prior to sleep confusion

  • March 5, 2025
  • 1 reply
  • 710 views

I'm working on getting the STM32G0 to stop mode. Im using WFI so it will wake on interrupt. Right now its immediately waking which is confusing me.

My understanding is that I should __disable_irq() first to prevent the interrupt handlers from being called which would potentially cause you to miss a wakeup flag because the handler cleared it. I can't make sense of this.

with the irq disabled the flag could still get set.  Thus, I think I need to disable the IRQ source itself. once the source is disabled then why would I need to call disable_irq?

Unless I should do as follows

1. Disable sources I don't want to wake the MCU
2. disable_irq
3. configure sources I _do_ want to wake the MCU
4. STOP

Is this the correct procedure?

    This topic has been closed for replies.

    1 reply

    Carl_GAuthor
    Graduate II
    March 5, 2025

    So much information out here its hard to know what to do. Things work much better without disabling the IRQ at all. And many examples show that __disable_Irq is not used. STM own example does not use disable_irq.