How to queue interrupts in stop mode on STM32L0

Post here first, or if you can't find a relevant section!
Post Reply
MeneerJacco
Posts: 2
Joined: Fri Nov 13, 2020 3:31 pm
Location: The Netherlands

How to queue interrupts in stop mode on STM32L0

Post by MeneerJacco »

Can anyone help?

I am trying to detach/queue an external interrupt on EXTI-4 and EXTI-5, so that they do not wake the processor during a critical stop mode deepsleep time of (for example) 1340ms.
During this time-out I want to go into stop mode with RTC for low power purposes.

On a previous processor, the ATMega328, I was able to detach an interrupt function in a way that it was handled after the lowpower sleep.
using just detachInterrupt().

Now, on the STM32L0, the interrupt wakes the processor (I can look at the RTC subSeconds to track time), but due to the limit of minimum 1000ms sleep, I cannot go back to sleep for the remaining milliseconds, in most cases (after 340ms)

Does anyone know how to detach, but still queue the interrupt (I still want it to set the ISR_Flag) while in stop mode so that I can sleep the full 1340ms and then handle the interrupt? I am unsuccessful using detachInterrupt().

Or does anyone know a way to sleep for less then 1000ms in stop mode?

Code: Select all

STM32LowPower lp;

Code: Select all

lp.attachInterruptWakeup(SENSOR_L, detect_Sensor_L, RISING);
lp.attachInterruptWakeup(SENSOR_R, detect_Sensor_R, RISING);

Code: Select all

lp.deepSleep(1340);
Sensor_L is on PIN PA4 (EXTI-4)
Sensor_R is on PIN PA5 (EXTI-5)

Code: Select all

void detect_Sensor_L()
{
  ISR_Flag_S1 = true;
}

void detect_Sensor_R()
{
  ISR_Flag_S2 = true;
}
I am using STM32duino RTC lib v1.1.0 and STM32duino Low Power lib v1.1.0

User avatar
fpiSTM
Posts: 780
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 30
Location: Le Mans
Contact:

Re: How to queue interrupts in stop mode on STM32L0

Post by fpiSTM »

First, library 1.1.0 are not released officially yet.
I guess you used idle or sleep mode (not deep sleep nor shutdown) as they work in __WFI.

The new version can handle small sleep time than 1000ms depending of the prediv factor set. I guess also you used the core 1.9.0 that's why you don't have this improvements as the rtc and low power drivers moved to the related libraries in 2.0.0. For backward compatibility libraries check the core version and use the proper drivers.

Maybe you have this issue, when using detachInterrupt() you should use this just after to avoid any spurious wakeup:

Code: Select all

detachInterrupt(pin);
__DSB();
__ISB();

MeneerJacco
Posts: 2
Joined: Fri Nov 13, 2020 3:31 pm
Location: The Netherlands

Re: How to queue interrupts in stop mode on STM32L0

Post by MeneerJacco »

fpiSTM wrote:
Fri Nov 13, 2020 4:51 pm
First, library 1.1.0 are not released officially yet.
I guess you used idle or sleep mode (not deep sleep nor shutdown) as they work in __WFI.

The new version can handle small sleep time than 1000ms depending of the prediv factor set. I guess also you used the core 1.9.0 that's why you don't have this improvements as the rtc and low power drivers moved to the related libraries in 2.0.0. For backward compatibility libraries check the core version and use the proper drivers.

Maybe you have this issue, when using detachInterrupt() you should use this just after to avoid any spurious wakeup:

Code: Select all

detachInterrupt(pin);
__DSB();
__ISB();
Thanks for the quick response.

I am indeed still on core 1.9.0, using PlatformIO in Visual Studio Code.
It displays the version installed is: 4.10900.200819 (1.9.0)
It is now clear why it is not working as expected.

Also thanks for letting me know about __DSB() and __ISB().
Should definitely not hurt to implement those, just in case.

Post Reply

Return to “General discussion”