← index #4389PR #16052
Related · high · value 0.094
QUERY · ISSUE

esp8266: Necessity for UART flush

openby cemoxopened 2019-01-01updated 2019-07-06
port-esp8266

This is rather recommendation than issue. The code below sends a string message from UART1 and is supposed to pull the output pin LOW :

mypin.on()
uart1.write("a long sentence")
mypin.off()

when I checked the signal (part tx and output) with logic analyzer, I saw that pin is pulled low long before the uart transmission has been completed. A function like uart.flash() which checks the relevant uart status bits for completion of the transmission would be very handy.

CANDIDATE · PULL REQUEST

rp2/machine_uart: Make it so TX is done only when no longer busy.

mergedby dpgeorgeopened 2024-10-21updated 2024-10-21
port-rp2

Summary

When flushing a UART on the rp2 port, it returns just before the last character is sent out the wire.

Fix this by waiting until the BUSY flag is cleared.

Testing

TODO: the tests/extmod/machine_uart_tx.py test needs updating to cover this case. Currently that test checks that transmit time is less than the expected time, and on rp2 the transmit+flush time is quite a bit less than expected (because it returns while there's still a byte left to transmit). Rather it should be changed so transmit time is very close to the expected time.

Edit: that's now done. Also docs updated.

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