machine.lightsleep() won't wake using ExtInt() when timer wakeup is used in the same program
Port, board and/or hardware
Arduino Portenta H7
MicroPython version
MicroPython v1.24.1 on 2024-11-29; Arduino Portenta H7 with STM32H747
I am waking machine.lightsleep() in two different ways- using ExtInt() and using time delay. This works as expected for the first iteration, after which the system goes only to timer-based wakeup.
Reproduction
Copy-paste and run the following examples on Arduino Portenta H7 using Arduino Lab for MicroPython
Eg 1:
import machine, pyb
from pyb import LED
red_led = LED(1)
green_led = LED(2)
blue_led = LED(3)
# Callback for ExtInT
def cb():
pass
# ExtInt()
pin = pyb.Pin("D6", pyb.Pin.IN, pyb.Pin.PULL_DOWN)
ext = pyb.ExtInt(pin, pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_DOWN, cb)
# Function called in main loop
def body():
machine.lightsleep(10*60*1000)
green_led.on()
# Main loop
while True:
blue_led.on()
pyb.delay(1000)
machine.lightsleep()
blue_led.off()
pyb.delay(1000)
red_led.on()
pyb.delay(1000)
red_led.off()
machine.lightsleep(10000)
Eg 2:
import machine, pyb
# Callback for ExtInT
def cb(_):
pass
# ExtInt()
pin = pyb.Pin("D6", pyb.Pin.IN, pyb.Pin.PULL_DOWN)
ext = pyb.ExtInt(pin, pyb.ExtInt.IRQ_FALLING, pyb.Pin.PULL_DOWN, cb)
# Function called in main loop
def body():
machine.lightsleep(10000)
pyb.LED(3).on()
pyb.delay(5000)
pyb.LED(3).off()
# Main loop
while True:
pyb.LED(1).on()
pyb.delay(5000)
pyb.LED(1).off()
machine.lightsleep()
pyb.LED(2).on()
pyb.delay(5000)
pyb.LED(2).off()
body()
Expected behaviour
After the first iteration, the device should wakeup on external interruption as well as timer.
Observed behaviour
After the first iteration, the device wakes up only on timer.
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree
ESP32 timer wake up repeating
I'm using timer wakeup from light sleep with:
machine.lightsleep(30000) #sleep 30s
after 30 the esp32 wakes, disable peripherals and sleep indefinitely with:
machine.lightsleep()
but the 30s wake timer keeps repeating and didn't find any way to disable wake source