You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ESP32 using PlatformIO Espressif1.9 and Arduino framework
Description:
I have to toggle GPIO around UART rx and tx activities, porting code from AVR Arduino. This does not work due to a bug in the HardwareSerial.cpp of the ESP32 Arduino framework
On Arduino the Serial.flush() flushes ONLY the TX buffer (to flush the RX, you just read it to end). This how it is documented and implemented (this is also true of SoftSerial).
Code:
On ESP32, the code of HardwareSerial.cpp is
voidHardwareSerial::flush()
{
uartFlush(_uart);
}
and in esp32-hal-uart.c, the code of uartFlush() flushes the output AND ERRONEOUSLY THE INPUT. This cause data loss on the input when we flush output.
voiduartFlush(uart_t* uart)
{
if(uart == NULL) {
return;
}
UART_MUTEX_LOCK();
while(uart->dev->status.txfifo_cnt || uart->dev->status.st_utx_out);
//Due to hardware issue, we can not use fifo_rst to reset uart fifo.//See description about UART_TXFIFO_RST and UART_RXFIFO_RST in <<esp32_technical_reference_manual>> v2.6 or later.// we read the data out and make `fifo_len == 0 && rd_addr == wr_addr`.while(uart->dev->status.rxfifo_cnt != 0 || (uart->dev->mem_rx_status.wr_addr != uart->dev->mem_rx_status.rd_addr)) {
READ_PERI_REG(UART_FIFO_REG(uart->num));
}
UART_MUTEX_UNLOCK();
}
The text was updated successfully, but these errors were encountered:
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
Hardware:
ESP32 using PlatformIO Espressif1.9 and Arduino framework
Description:
I have to toggle GPIO around UART rx and tx activities, porting code from AVR Arduino. This does not work due to a bug in the HardwareSerial.cpp of the ESP32 Arduino framework
On Arduino the Serial.flush() flushes ONLY the TX buffer (to flush the RX, you just read it to end). This how it is documented and implemented (this is also true of SoftSerial).
Code:
On ESP32, the code of HardwareSerial.cpp is
and in esp32-hal-uart.c, the code of uartFlush() flushes the output AND ERRONEOUSLY THE INPUT. This cause data loss on the input when we flush output.
The text was updated successfully, but these errors were encountered: