RTS signal not going low after end of transmission
Posted: 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.
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.
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.
- void uart_rs485_init(uint32_t baud_rate){
- int intr_alloc_flags = 0;
- uart_driver_install(RS485_UART_PORT, RS485_UART_BUFFER_SIZE * 2, 0, 0, NULL, intr_alloc_flags);
- uart_config_t uart_config = {
- .baud_rate = baud_rate,
- .data_bits = UART_DATA_8_BITS,
- .parity = UART_PARITY_DISABLE,
- .stop_bits = UART_STOP_BITS_1,
- .flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
- .source_clk = UART_SCLK_APB,
- };
- uart_param_config(RS485_UART_PORT, &uart_config);
- uart_set_pin(RS485_UART_PORT, RS485_UART_TXD_PIN, RS485_UART_RXD_PIN, RS485_UART_RTS_PIN, UART_PIN_NO_CHANGE);
- uart_set_mode(RS485_UART_PORT, UART_HW_FLOWCTRL_RTS);
- return;
- }
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.