Skip to content

RP2350 / Pico 2 machine.lightsleep not working correctly #15622

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

Open
geerlingguy opened this issue Aug 8, 2024 · 2 comments
Open

RP2350 / Pico 2 machine.lightsleep not working correctly #15622

geerlingguy opened this issue Aug 8, 2024 · 2 comments

Comments

@geerlingguy
Copy link

Port, board and/or hardware

Pico 2 / RP2350

MicroPython version

MicroPython v1.24.0-preview.201.g269a0e0e1 on 2024-08-09; Raspberry Pi Pico2 with RP2350

Reproduction

  1. Install latest Firmware from https://micropython.org/download/RPI_PICO2/
  2. Implement machine.lightsleep(5000) in your code
  3. Run code.

Expected behaviour

Expected Pico 2 to enter lightsleep mode for 5 seconds, then continue to next bit of code.

Observed behaviour

lightsleep is maybe entered for a cycle or so, but code carries on and never stops executing for any time value I enter for lightsleep.

Additional Information

Complete code example:

# Lightsleep MicroPython example.
from machine import Pin
import time
led = Pin(25, Pin.OUT)

while True:
    led.toggle()
    time.sleep_ms(5000)
    led.toggle()
    machine.lightsleep(5000)

Code of Conduct

Yes, I agree

@felixdoerre
Copy link
Contributor

I think the early wakeup is already noted in the initial PR for the pico2 (#15619 (comment)):

here are some issues with lightsleep mode on ARM

@simon-77
Copy link

I can confirm the same behavior on Pico W (RP2040) with latest Micropython stable release (v1.24.0).

I have slightly modified this example to:

# Lightsleep MicroPython example.
from machine import Pin
import machine
import time
led = Pin('LED', Pin.OUT)

while True:
    for _ in range(5):
        led.toggle()
        time.sleep_ms(200)
    time.sleep(1)
    machine.lightsleep(5000)    

On older Micropython Releases (v1.22.0 & v1.23.0) the above code has an expected delay of 6 seconds between the short pulses.

Using the latest Micropython Release (v1.24.0), the same code has only a 1 second delay between the short pulses - the lightsleep instruction is "ignored".


Sidenote:
When replacing machine.lightsleep with machine.deepsleep, there is also only a 1 second delay after the short pulses. Then the pico will reset. This can be observed as for the longer 1 second delay the LED is always "on".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants