Skip to content

Commit 29288a0

Browse files
committed
searching for failure of detection on 3686400 bauds
1 parent 612149e commit 29288a0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: cores/esp32/esp32-hal-uart.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ unsigned long uartBaudrateDetect(uart_t *uart, bool flg)
653653

654654
UART_MUTEX_LOCK();
655655
log_i("rxd_edge_cnt = %d lowpulse_min_cnt = %d hightpulse_min_cnt = %d", hw->rxd_cnt.rxd_edge_cnt, hw->lowpulse.lowpulse_min_cnt, hw->highpulse.highpulse_min_cnt);
656-
unsigned long ret = (hw->lowpulse.lowpulse_min_cnt + hw->highpulse.highpulse_min_cnt) >> 1;
656+
unsigned long ret = hw->lowpulse.lowpulse_min_cnt + hw->highpulse.highpulse_min_cnt;
657657
UART_MUTEX_UNLOCK();
658658

659659
return ret;
@@ -778,7 +778,7 @@ uartDetectBaudrate(uart_t *uart)
778778
// log_v("Divisor: %d", divisor);
779779
// log_v("Divider: %d", div16);
780780

781-
baudrate = sclk_freq / (divisor * 2);
781+
baudrate = sclk_freq / divisor;
782782

783783
// switch(clk_src)
784784
// {
@@ -827,8 +827,11 @@ uartDetectBaudrate(uart_t *uart)
827827
}
828828
}
829829

830-
log_v("Rounded %d to %d (b: %d) (n: %d)", baudrate, default_rates[i], default_rates[i-1], default_rates[i+1]); //THIS WILL OVERFLOW, only for testing now
831-
830+
log_v("Rounded\t%d\tto\t%d", baudrate, default_rates[i]);
831+
log_v("From Previous\t( %d )\t:\t( %d )", default_rates[i-1], baudrate - default_rates[i-1] ); //THIS WILL OVERFLOW, only for testing now
832+
log_v("From Current\t( %d )\t:\t( %d )", default_rates[i], default_rates[i] - baudrate); //THIS WILL OVERFLOW, only for testing now
833+
log_v("From Next\t( %d )\t:\t( %d )", default_rates[i+1], default_rates[i+1] - baudrate); //THIS WILL OVERFLOW, only for testing now
834+
832835
return default_rates[i];
833836
#else
834837
#ifdef CONFIG_IDF_TARGET_ESP32C3

0 commit comments

Comments
 (0)