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

Document that UART TX should be set up first #2914

Merged
merged 1 commit into from
Jan 9, 2025
Merged

Conversation

bugadani
Copy link
Contributor

@bugadani bugadani commented Jan 9, 2025

Resolves #2911 by changing the documentation.

The issue is caused by the loopback setup in our tests. When you connect RX, but the pin is not configured, there is a possibility that the pin has a low level for some time (which we try to counteract with a pullup resistor). This may cause the UART peripheral to register a start condition, and receive a byte - which, because we connect TX immediately, and set it to high, will be a 0xFF. The hardware doesn't seem to notice that the start bit is too short.

When we set TX first, we set a high level on the pin, and then the peripheral does not misdetect a start bit on the subsequent RX configuration.

ESP-IDF sets the pins together, TX-first, likely because of this same phenomenon.

This issue really only affects cases where the ESP32 listens to its own output, and the line is only driven by the ESP32. In other cases, the RX line's level should be determined by an external device and so we can't say what causes a low signal level - communication, break, or some other cause.

As the order of the pin setup is set by the user, the pins may be configured mid-operation and I can't really find a way to stop receiving a byte anyway, I'm not sure what else we can do other than document that the user should be careful when listening to their own output.

@bugadani bugadani added the skip-changelog No changelog modification needed label Jan 9, 2025
Copy link
Contributor

@bjoernQ bjoernQ left a comment

Choose a reason for hiding this comment

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

Thanks - makes sense

Copy link
Contributor

@JurajSadel JurajSadel left a comment

Choose a reason for hiding this comment

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

Thanks!

@JurajSadel JurajSadel added this pull request to the merge queue Jan 9, 2025
Merged via the queue into esp-rs:main with commit 409641d Jan 9, 2025
28 of 29 checks passed
@bugadani bugadani deleted the uart branch January 9, 2025 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog No changelog modification needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UART: The calling order of with_tx() and with_rx() builder functions might matter
3 participants