RS-485 half-duplex extra byte received.

sramberg2
Posts: 9
Joined: Tue Jul 20, 2021 9:35 pm

RS-485 half-duplex extra byte received.

Postby sramberg2 » Fri Jul 23, 2021 10:31 pm

IDF4.3
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.

Code: Untitled.c Select all

        } 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 {
I do not see the extra byte on the output of the RS-485 driver.

Any idea on how to prevent this extra byte?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: RS-485 half-duplex extra byte received.

Postby WiFive » Fri Jul 23, 2021 10:41 pm

Did you try moving it after uart_hal_set_rts

HitecSmartHome
Posts: 12
Joined: Mon Mar 18, 2024 9:22 am

Re: RS-485 half-duplex extra byte received.

Postby HitecSmartHome » Wed Mar 19, 2025 9:56 am

We experience the same problem. We got `0x00` byte frames on every uart. In our case these are occasional and we observe them sometimes multiple times / minute but there are cases where it isn't there for several minutes. Increasing the RX symbol timeout seems to help but it slows down the communication.

Who is online

Users browsing this forum: No registered users and 12 guests