STM32 - detachInterrupt and deepSleep
Posted: Wed Feb 10, 2021 2:55 pm
Hi,
Working on STM32 project in which I have an external sensor with interrupt (PA11).
When in deepsleep I am looking at 2 different ways to wake up.
For the second scenario I had the idea to use detachInterrupt() and go to sleep and wait for the timer to expire.
However the following is happening:
Any suggestions why this is happening and what I am doing wrong?
Thanks!
Working on STM32 project in which I have an external sensor with interrupt (PA11).
When in deepsleep I am looking at 2 different ways to wake up.
- (1) Sensor wakes up the MCU thru an interrupt
- (2) MCU wakes up "itself" due to timer that runs out (e.g. lp.deepsleep(60000))
In this case the MCU should never wake up from the external sensor interrupt (PA11)
For the second scenario I had the idea to use detachInterrupt() and go to sleep and wait for the timer to expire.
However the following is happening:
- After powerup it goes to sleep and wakes up after 1 minutes, goes to sleep, wakes up etc etc -> no problem.
But when triggering the sensor (motion) the MCU wakes up and not able to sleep again
Code: Select all
STM32LowPower lp;
lp.attachInterruptWakeup(PA11, wakeUpNow, LOW, DEEP_SLEEP_MODE);
Code: Select all
void sleepLight2(bool useIntFromSensor)
{
if (useIntFromSensor == true)
{
lp.attachInterruptWakeup(PA11, wakeUpNow, LOW, DEEP_SLEEP_MODE);
interruptFlagMotion = false;
}
else
{ // Disable the interrupt from sensor
detachInterrupt(PA11);
__DSB();
__ISB();
}
// ***** Deepsleep
interruptFlagMotion = false;
lp.deepSleep( 60000 ); // deepsleep 1 minute
} // end of sleepLight2
Thanks!