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

feat: adds baudrate detection to S3 and C3 using LL API for all SoC #9261

Merged
merged 6 commits into from
Feb 21, 2024

Conversation

SuGlider
Copy link
Collaborator

@SuGlider SuGlider commented Feb 17, 2024

Description of Change

Adds Baud Rate detection into V2.0.15 for the ESP32-C3 and ESP32-S3.
Those 2 SoC have a maximum resolution of 12 bits, while ESP32 and ESP32-S2 have a resolution of 20 bits.
The implication is that ESP32-S3 and ESP32-C3 can not detect any baud rate under 9600 baud.
This is because the calculation of the minimum baud = 40MHz / 4096 =~ 9600

After testing all the 3 possible Clock Source for UART, it is clear that the most precise is when using XTAL as CLK SOURCE.
Using APB or RTC do not produce good results for the C3 or S3.

In case that the calculate baud rate uses the maximum 12 bits resolution (4095), the code will issue a warning message (log_w).
This is because it may be wrong as it can be in the range of 300 to 9600 baud, but the calculation will always be 9600.

This PR shall replace #7782

This PR also fixes void uartSetBaudRate(uart_t* uart, uint32_t baud_rate) and uint32_t uartGetBaudRate(uart_t* uart)for the ESP32 and ESP32-S2 when the APB Frequency is lower than 80MHz.

Tests scenarios

Using the Serial example in https://github.com/espressif/arduino-esp32/blob/master/libraries/ESP32/examples/Serial/BaudRateDetect_Demo/BaudRateDetect_Demo.ino

Related links

Closes #7782

@SuGlider SuGlider self-assigned this Feb 17, 2024
@SuGlider SuGlider marked this pull request as draft February 17, 2024 01:45
@lucasssvaz lucasssvaz added the Status: Pending Merge Pull Request is ready to be merged label Feb 19, 2024
@me-no-dev me-no-dev merged commit 43b15f3 into release/v2.x Feb 21, 2024
42 checks passed
@me-no-dev me-no-dev deleted the 2.0.15-S3_C3-baud-rate-detect branch February 21, 2024 14:23
@OpenUAS
Copy link

OpenUAS commented Feb 23, 2024

🎊 Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Peripheral: UART Status: Pending Merge Pull Request is ready to be merged
Projects
Development

Successfully merging this pull request may close these issues.

5 participants