Understanding why we need RTS delay for RS485 communication

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Understanding why we need RTS delay for RS485 communication

1,672 Views
FabienLahoudere
Contributor I

On our product, RS485 communication requires to add some delays before setting RTS.

Without these delays, it’s not possible to repeat messages sent to a connected device, the second transmission always fails.

We found a patch to fix the issue but we want to understand why this delay is needed.

Below we summarize linux(5.4) imx uart driver.

The first transaction always succeed.

If we do not add a delay before imx_uart_transmit_buffer, imx_uart_int never return successfully.

INIT ONCE: imx_uart_rts_inactive: do mctrl_gpio_set(... 2) LEAD TO: trace_gpio_value 91 0 0 = RTS INACTIVE = RECEIVE

LOOP {
  imx_uart_start_tx
  imx_uart_rts_active: LEAD TO: trace_gpio_value 91 0 1 = RTS ACTIVE = SEND
  imx_uart_stop_rx

  imx_uart_int (irq=65) USR1_TRDY||USR2_TXDC, ucr1=2040
  /*** DELAY HERE OR EARLIER (e.g. imx_uart_start_tx, even before the imx_uart_rts_active) FIXES IT ***/
  imx_uart_transmit_buffer send whole TX buffer (with imx_uart_writel(sport, sport->port.x_char, URTX0);)
  /*** DELAY HERE OR LATER DOES ***NOT*** FIX IT ***/

   imx_uart_stop_tx

   imx_uart_int (irq=65) USR1_TRDY||USR2_TXDC, ucr1=0040
   imx_uart_transmit_buffer uart_circ_empty

   imx_uart_stop_tx continued...
   imx_uart_rts_inactive: do mctrl_gpio_set(... 2) RTS INACTIVE = RECEIVE
   imx_uart_start_rx

  imx_uart_int (irq=65) USR1_RRDY|USR1_AGTIM, usr1=0200 THERE IS NO USR1_RRDY|USR1_AGTIM IRQ IN CASE OF FAILURE <----
  __imx_uart_rxint read whole RX buffer
}

Can you help us understanding what happen and why we need this delay even before setting RTS active ?

Thanks

0 Kudos
2 Replies

1,638 Views
nvbolhuis2
Contributor I

It might be a limitation of the connected RS485 device.
You seem to be getting TXDC, so this means the transmission was OK.
Does it fail for other devices?
Does it fail at lower baud rates?

0 Kudos

1,645 Views
FabienLahoudere
Contributor I

Any idea ? 

0 Kudos