← index #9006PR #8832
Likely Duplicate · medium · value 2.594
QUERY · ISSUE

Lightsleep with sleep period set to a value never waking

openby guillochonopened 2022-08-01updated 2026-03-09
bugport-rp2

I'm currently running a program on a Pico W where I am trying to lightsleep(5000). Unfortunately, the program seems to never wake up again after this call. Using a time.sleep instead and the Pico does wake up as expected, but of course with much more power draw.

I am running this nightly: https://micropython.org/resources/firmware/rp2-pico-w-20220729-unstable-v1.19.1-223-g963e599ec.uf2

CANDIDATE · PULL REQUEST

rp2/modmachine: Implement lightsleep() with optional sleep period.

mergedby dpgeorgeopened 2022-06-28updated 2023-03-13
port-rp2

This gets basic machine.lightsleep([n]) working on the rp2 port.

It supports:

  • Calling lightsleep without a specified period, in which case it uses xosc dormant mode. There's currently no way to wake it up from this state, unless you write to raw registers to enable a GPIO wake up source.
  • Calling lightsleep with a period n in milliseconds. This period must be less than about 72 minutes and uses timer alarm3 to wake it up.

The RTC continues to run during lightsleep, but other peripherals have their clock turned off during the sleep.

It doesn't yet support:

  • Longer periods than 72 minutes (could use the RTC for this).
  • Wake up from GPIO IRQ.

Fixes issue #8770.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied