Sending 7 bytes out UART2 configured as RS485 Half-duplex every 80ms at 115200 baudrate.
While debugging this issue, https://www.esp32.com/viewtopic.php?f=13&t=21835
Occasionally I would see a data byte in the RX FIFO following a transmission. The byte was always 0x00.
I modified the TX DONE interrupt, in UART.c, to disable the RX FIFO flushing and I received the extra byte close to 100% of the time. It appears that the RX FIFO flush would remove this extra byte most of the time.
- } else if(uart_intr_status & UART_INTR_TX_DONE) {
- if (UART_IS_MODE_SET(uart_num, UART_MODE_RS485_HALF_DUPLEX) && uart_hal_is_tx_idle(&(uart_context[uart_num].hal)) != true) {
- // The TX_DONE interrupt is triggered but transmit is active
- // then postpone interrupt processing for next interrupt
- uart_event.type = UART_EVENT_MAX;
- } else {
- // Workaround for RS485: If the RS485 half duplex mode is active
- // and transmitter is in idle state then reset received buffer and reset RTS pin
- // skip this behavior for other UART modes
- UART_ENTER_CRITICAL_ISR(&(uart_context[uart_num].spinlock));
- uart_hal_disable_intr_mask(&(uart_context[uart_num].hal), UART_INTR_TX_DONE);
- if (UART_IS_MODE_SET(uart_num, UART_MODE_RS485_HALF_DUPLEX)) {
- //SRR 7/23/21 uart_hal_rxfifo_rst(&(uart_context[uart_num].hal));
- uart_hal_set_rts(&(uart_context[uart_num].hal), 1);
- }
- UART_EXIT_CRITICAL_ISR(&(uart_context[uart_num].spinlock));
- uart_hal_clr_intsts_mask(&(uart_context[uart_num].hal), UART_INTR_TX_DONE);
- xSemaphoreGiveFromISR(p_uart_obj[uart_num]->tx_done_sem, &HPTaskAwoken);
- }
- } else {
Any idea on how to prevent this extra byte?