Raspberry Pi Pico - No UART after lightsleep when not connected to USB
Port, board and/or hardware
Raspberry Pi Pico (1)
MicroPython version
MicroPython v1.24.1 on 2024-11-29; Raspberry Pi Pico with RP2040
Reproduction
Run this code in main.py
from machine import UART, Pin, lightsleep
from utime import sleep_ms
UART_BAUD_RATE=9600
UART_BITS=8
UART_PARITY=None
UART_STOP=1
UART_INSTANCE=0
TX_PIN = 16
RX_PIN=17
uart = UART(UART_INSTANCE, baudrate=UART_BAUD_RATE, tx=Pin(TX_PIN), rx=Pin(RX_PIN), bits=UART_BITS, parity=UART_PARITY, stop=UART_STOP)
sleep_ms(5000) # give windows a chance to identify device before everything is messed up
while True:
print ("run loop")
uart.write("second uart")
uart.flush()
lightsleep(1000)
sleep_ms(10) # wait for everything to wake up
Expected behaviour
Expected to putout this on second uart0 (not USB Uart, but second UART device). This is also the case when constantly connected to PC (Windows 10 in my case, but doesn't matter).
second uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uartsecond uart
Observed behaviour
This is observed when connected to a power bank via USB instead of PC (same behaviour with other powering methods)
second uartsgV▒sc▒▒sc▒▒sg▒▒sg▒▒wg▒▒sg▒▒sg▒▒sg▒▒sg▒▒sg▒▒sg▒▒sg▒▒sg▒▒wg▒▒sg▒▒wg▒▒sc▒▒
Additional Information
No, I've provided everything above.
PS: My personal theory is that uart is not put to sleep when connected to PC and therefore works fine, but is put to slepp when no PC connection is present and does not wake properly ...
Code of Conduct
Yes, I agree
Serial com and external power supply
Port, board and/or hardware
rp2, raspberry pico
MicroPython version
MicroPython v1.24.1 on 2024-11-29; Raspberry Pi Pico with RP2040
Reproduction
- Start a code with serial printing such as:
import time
while True:
print(time.time())
time.sleep(0.1)
- Connect external power supply (+5V or 3V3)
- Disconnect usb
- Wait ~4 s
- Reconnect usb
Expected behaviour
When you reconnect USB, the board should be normally detected as CDC Serial device and printing.
Observed behaviour
When you reconnect USB the board is not detected anymore and it seems the program has been interrupted.
Additional Information
I suspect something like a buffer overflow on the serial output hardware is happening.
If the usb is reconnected quickly (in 1 second or so), the board is well detected.
Code of Conduct
Yes, I agree