-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
rp2/modmachine: Implement lightsleep() with optional sleep period. #8832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This works well, and it keeps the |
Thanks for testing, that is very helpful. I measured about 1.55mA when doing |
I've now done a proper measurement with |
d0177fb
to
3aa69fb
Compare
This gets basic machine.lightsleep([n]) behaviour 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, or waking up from GPIO IRQ. Measured current consumption from the USB port on a PICO board is about 1.5mA when doing machine.lightsleep(5000), and about 0.9mA when doing machine.lightsleep(). Addresses issue micropython#8770. Signed-off-by: Damien George <damien@micropython.org>
3aa69fb
to
b004e7e
Compare
I've given this a try in a program and the Pico never wakes up after the sleep 😞 (the program behaves normally with a I was using the nightly build for the Pico W, this one in particular: https://micropython.org/resources/firmware/rp2-pico-w-20220729-unstable-v1.19.1-223-g963e599ec.uf2 Does |
Tried with the same build as above on Pico W Unfortuneately any value other than 1 never returns
|
Tried with build [v1.19.1-428-gb41aaaa8a (2022-09-19) .uf2 on a Pico W and having the same issue @guillochon and @mikerr report - |
See #9438 for a fix for the lightsleep-on-pico-w issues reported here. |
I am having a problem with reading a UART after it comes out of lightsleep. Is there something I need to do to make it work? |
Which board, firmware version and UART configuration do you use? |
I figured out whats happening. The other device was writing before it came out of lightsleep mode. If I read the uart with an interrupt will that kick it out of lightsleep mode? |
This gets basic
machine.lightsleep([n])
working on the rp2 port.It supports:
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.lightsleep
with a periodn
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:
Fixes issue #8770.