uart.any freezing when second data has sended
main.py in rasberry pi pico
from machine import UART
from time import sleep
uart = UART(0,9600)
def read():
global uart
data = uart.read()
while True:
if uart.any():
read()
sleep(0.3)
When i open the serial port with the same settings as rasberry pi pico's serial port, its works nicely. But then, I open Arduino Uno editor then serial port screen, I'm able to send the first data but when I send the second data, it's just freezing forever.
I tried with different rasberry pi pico but the result is the same.
Raspberry Pico W MicroPython execution freezes a few seconds after disconnecting screen from UART
Discussed in https://github.com/orgs/micropython/discussions/9633
<div type='discussions-op-text'>
<sup>Originally posted by cirosantilli October 15, 2022</sup>
I got my program running fine as explained at: https://stackoverflow.com/questions/66183596/how-can-you-make-a-micropython-program-on-a-raspberry-pi-pico-autorun/74078142#74078142
I'm installing a main.py that does:
import machine
import time
led = machine.Pin('LED', machine.Pin.OUT)
# For Rpi Pico (non-W) it was like this instead apparently.
# led = Pin(25, Pin.OUT)
i = 0
while (True):
led.toggle()
print(i)
time.sleep(.5)
i += 1
When I power the device on by plugging the USB to my laptop, it seems to run fine, with the LED blinking.
Then, if I connect from my laptop to the UART with:
screen /dev/ttyACM0 115200
I can see the numbers coming out on my host terminal correctly, and the LED still blinks, all as expected.
However, when I disconnect from screen with Ctrl-A K, after a few seconds, the LED stops blinking! It takes something around 15 seconds for it to stop, but it does so every time I tested.
If I reconnect the UART again with:
screen /dev/ttyACM0 115200
it starts blinking again.
Also also noticed that after I reconnect the UART and execution resumes, the count has increased much less than the actual time passed, so one possibility is that the Pico is going into some slow low power mode?
Micropython firmware: rp2-pico-w-20221014-unstable-v1.19.1-544-g89b320737.uf2, Ubuntu 22.04 host.
Also asked at:
- https://stackoverflow.com/questions/74081960/raspberry-pico-w-micropython-execution-freezes-a-few-seconds-after-disconnecting</div>