cancel
Showing results for 
Search instead for 
Did you mean: 

Clear Interrupts Prior to sleep confusion

Carl_G
Senior

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?

1 REPLY 1
Carl_G
Senior

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.