RTS signal not going low after end of transmission

WildPointer
Posts: 4
Joined: Sat May 04, 2024 4:24 pm

RTS signal not going low after end of transmission

Postby WildPointer » Mon Jun 24, 2024 2:16 pm

Going straight to the point:
The `RTS` signal from the ESP32 is sometimes going low about 300 micro-seconds after the transmission has ended. This causes the RS485 driver chip in my board (Texas Instruments SN65176BDR) to keep control of the bus even when it is the slave's turn to respond. The slave device responds either way and it's response gets attenuated enough for the ESP32 to loose the first few bytes received. See the attached images of the Bus Contention in the oscilloscope and my schematic.

My UART setup code is the one below.
  1.     void uart_rs485_init(uint32_t baud_rate){
  2.         int intr_alloc_flags = 0;
  3.         uart_driver_install(RS485_UART_PORT, RS485_UART_BUFFER_SIZE * 2, 0, 0, NULL, intr_alloc_flags);
  4.      
  5.         uart_config_t uart_config = {
  6.             .baud_rate  =   baud_rate,
  7.             .data_bits  =   UART_DATA_8_BITS,
  8.             .parity     =   UART_PARITY_DISABLE,
  9.             .stop_bits  =   UART_STOP_BITS_1,
  10.             .flow_ctrl  =   UART_HW_FLOWCTRL_DISABLE,
  11.             .source_clk =   UART_SCLK_APB,
  12.         };
  13.         uart_param_config(RS485_UART_PORT, &uart_config);
  14.         uart_set_pin(RS485_UART_PORT, RS485_UART_TXD_PIN, RS485_UART_RXD_PIN, RS485_UART_RTS_PIN, UART_PIN_NO_CHANGE);
  15.         uart_set_mode(RS485_UART_PORT, UART_HW_FLOWCTRL_RTS);
  16.      
  17.         return;
  18.     }
I have to note that the `flow_control` member of the `uart_config_t ` typed variable is set to `UART_HW_FLOWCTRL_DISABLE` and that using `UART_HW_FLOWCTRL_RTS` causes errors in the communication.
My code is heavily based on the code for the UART RS485 Echo Example by Espressif https://github.com/espressif/esp-idf/tr ... echo_rs485

Has anyone had problems like this? What am I doing wrong? Why is this behavior occurring only sporadically?
THANKS !!

Extra info is that this is not an issue with slower (reduced baud rates) devices. 9600 baud/s works but a 115200 baud/s device doesn't.
Attachments
RS485 - bus contention - EDIT.png
Bus Contention event in the RS485 communication channel.
- Yellow trace is the RS485-A line with respect to GND_ISO
- Violet trace is the RTS signal at the Drive Enable (DE) pin of the bus driver chip with respect to GND_ISO

You can see RTS remaining high even during the slave device's response causing an attenuation of the latter.
RS485 - bus contention - EDIT.png (51.62 KiB) Viewed 1589 times
RS485 - healthy - EDIT.png
Healthy RS485 communication.
- Yellow trace is the RS485-A line
- Violet trace is the RTS signal at the Drive Enable (DE) pin of the bus driver chip.

The RTS signal goes low on time to allow the response without Bus Contention

The master's request and slave's response can be recognized.
RS485 - healthy - EDIT.png (42.9 KiB) Viewed 1589 times

Who is online

Users browsing this forum: Majestic-12 [Bot] and 65 guests