From d303f25427052a0355ef994737efa56d4f010deb Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Thu, 15 Aug 2024 11:23:40 -0300 Subject: [PATCH] fix(uart): clock source Problem detected with ESP32 and ESP32-S2 when the baudrate goes to 460600 bps. REF_TICK (2MHz) seem not to work properly. Limiting the use of REF_TICK for up to 205 Kbps. --- cores/esp32/esp32-hal-uart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index 0fbe4b3feb3..7608502d0f8 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -508,8 +508,8 @@ uart_t *uartBegin( #if SOC_UART_SUPPORT_XTAL_CLK uart_config.source_clk = UART_SCLK_XTAL; // valid for C2, S3, C3, C6, H2 and P4 #elif SOC_UART_SUPPORT_REF_TICK - if (baudrate <= 1000000) { - uart_config.source_clk = UART_SCLK_REF_TICK; // valid for ESP32, S2 - MAX supported baud rate is 1MHz + if (baudrate <= 250000) { + uart_config.source_clk = UART_SCLK_REF_TICK; // valid for ESP32, S2 - MAX supported baud rate is 250 Kbps } else { uart_config.source_clk = UART_SCLK_APB; // baudrate may change with the APB Frequency! }