I'm using an external interrupt triggered by a button press to wake up an STM32F030K6 from STOP mode. I was wondering if there's any way of distinguishing, within the interrupt handler, a button press that triggered a wakeup from a regular button press.
Electronic – Determine if button press triggered wakeup from STOP mode with STM32F0
interruptssleepstm32stm32f0
Related Topic
- Interrupts in AVR
- Electronic – Arduino Atmega328 sleep mode with internal timer interrupt
- Electronic – STM32 Wakeup from Stop mode using GPIO EXTI event
- Electronic – ESP8266: Differentiate wakeup due to sleep interval vs button press
- Electrical – STM32 External Interrupt via GPIO cannot be triggered after waking up from STOP mode
- Electrical – STM32 EXTI does not trigger interrupt
Best Answer
You always have the possibility to add that feature manually through setting a flag before you enter the STOP mode, and check if that flag is set in the interrupt handler.
As you might forget to do that every time you enter STOP mode, you could write a global function (like the compiler intrinsic) which sets the flag and enters STOP mode.
EDIT: I thought this bit would be helpful, but as @foldl found out, this bit seems to be set only in case of a wakeup from the wakeup pins and not from other pins. I haven't seen any other bit which might be useful for this.
The PWR_CSR register contains a wakeup flag bit (WUF, bit 0):
See Reference Manual Page 83.
So in your interrupt service routine, you can check this flag. Note however, that you have to manually clear it through setting the CWUF bit in the PWR_CR register: