ls1043 : How to use lpuart1 as an RS485 serial link ?

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

ls1043 : How to use lpuart1 as an RS485 serial link ?

2,005 Views
sergepayre
Contributor III

If I send string from a PC to my board,  the receipt of characters works correctly but when my send string from my board, the remote terminal receives only the last character.

The image below contains a record of RTS and TXT signals

F0000TEK.JPG


As you can see the transmission of the first character at 9600 baud starts 1.1 ms after the RTS signal goes low whereas according to the user manual of ls1043 this temp should be equal to 100 μS.
I try to set TXRTSPOL to 1 to invert RTS signal without success.

Why RTS output signal goes low even if I set TXRTSPOL bit ?

Why the transmission begin after 1,1 ms ?

Thanks for your help

0 Kudos
4 Replies

1,521 Views
sergepayre
Contributor III

Hi,

Excuse me I made a mistake into previous message

I partially solved my RS485 serial link problem with automatic flipping managed by fsl-lpuart driver.

I think that there are some errors in current an older source file fsl-lpuart.c. Indeed, the function supposed to configure the automatic reversal (lpuart_config_rs485) does not reach the correct registers of ls1043a. I create the following function :

static int lpuart32_config_rs485(struct uart_port *port, struct serial_rs485 *rs485)
{
    struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
    unsigned long temp;

    

   temp = lpuart32_read(port->membase + UARTMODIR) &   
      ~(UARTMODIR_TXRTSPOL | UARTMODIR_TXRTSE);
    lpuart32_write(temp, port->membase + UARTMODIR);

   /* clear unsupported configurations */
   rs485->delay_rts_before_send = 0;
   rs485->delay_rts_after_send = 0;
   rs485->flags &= ~SER_RS485_RX_DURING_TX;

   i f (rs485->flags & SER_RS485_ENABLED) {
      /* Enable auto RS-485 RTS mode */
      temp |= UARTMODIR_TXRTSE;
      temp |= UARTMODIR_TXRTSPOL;

      /*
      * RTS needs to be logic HIGH either during transer _or_ after
      * transfer, other variants are not supported by the hardware.
      */

      if (!(rs485->flags & (SER_RS485_RTS_ON_SEND |  SER_RS485_RTS_AFTER_SEND)))
         rs485->flags |= SER_RS485_RTS_ON_SEND;

      if (rs485->flags & SER_RS485_RTS_ON_SEND && rs485->flags & SER_RS485_RTS_AFTER_SEND)
          rs485->flags &= ~SER_RS485_RTS_AFTER_SEND;
   }

   /* Store the new configuration */
   sport->port.rs485 = *rs485;

   lpuart32_write(temp, port->membase + UARTMODIR);   
   return 0;
}

I still have more than the problem concerning the duration of 2 ms before the RTS signal is raised and the data sent (at 9600 bauds).

If I send characters by writing directly in the uart with devmem, I do not see this phenomenon.

for info i selected the type "fsl, ls1021a-lpuart" in my devicetree

I currently have no investigative track. Do you have an idea ?

Thank for your help

Best regards

0 Kudos

1,521 Views
alexander_yakov
NXP Employee
NXP Employee

I'm sorry, your question "I still have more than the problem concerning the duration of 2 ms before the RTS signal is raised and the data sent (at 9600 bauds)" is not quite clear.

Could you please clarify, which problem was solved and which problem was not solved?

0 Kudos

1,521 Views
sergepayre
Contributor III

Now I can send and received characters in RS485 mode using lpuart without error but when I have a delay of 2 ms between the RTS signal is raised and data sent.

This time is 100 μs at 9600 bauds when I write directly into lpuart register with the devmem utility as described in the ls1043a user manual.

Regards

0 Kudos

1,521 Views
alexander_yakov
NXP Employee
NXP Employee

Sorry for delayed response to this.

Please show CTS on the same scope capture.

If CTS is not used, than please tie it explicitly to inactive state, for example add pull-up resistor, and check if the problem appears in this case.


Have a great day,
Alexander
TIC

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------