Skip to content
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

espressif UART: clear input buf on creation to avoid stray byte #9193

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

dhalbert
Copy link
Collaborator

On some Espressif chips (noticed on ESP32-S3 and ESP32-C3, not ESP32-S2, did not test others), a strayjunk byte of some number of consecutive 1's may appear as the first byte in the input buffer. Easy fix is to wait at least one byte time and then clear the input buffer.

Test program:

import busio
import board

for baudrate in (110, 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 468000, 921600):
    u = busio.UART(board.TX, board.RX, baudrate=baudrate)
    print(baudrate, u.read())
    u.deinit()

When fixed, should print all Nones.

@dhalbert dhalbert requested review from tannewt and jepler April 19, 2024 23:57
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@tannewt tannewt merged commit cce3293 into adafruit:main Apr 22, 2024
191 checks passed
@dhalbert dhalbert deleted the espressif-uart-fix branch April 23, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ESP32-S3: Stray byte read on UART when first created
3 participants