Hardware Flow Control (RS485) for KE18F

cancel
Showing results for 
Search instead for 
Did you mean: 

Hardware Flow Control (RS485) for KE18F

862 Views
onurdemirel
Contributor III

Hello,

I am using TWR-KE18F board with elevator and TWR-IND-IO board. I want to use RS485 part of the IO card. I am using MOXA UPort 1250 to see the results in computer. 

All examples of LPUART has no hardware flow control. So I couldn't inspire from examples. In TWR-IND-IO card there is a ISO1176DW RS485 Transceiver. In this board the transceiver is connected in 'Reciever always on' configuration as default. For receiving nothing is needed; but for transmitting, Driver Enable pin is connected to RTS pin. 

First, I tried to set a GPIO pin High and connected to RTS pin of transceiver. I tried to send a string to that uart port and receive meaningless things. It is not all zeros or not all ones. But neither a shifted version or similar bits that I sent. 

Then I find MODIR register of this processor have internal RTS control. I couldn't find processor's reference manual, but I get help from this question and the answer given by xiangjun.rong. In default driver fsl_lpuart.c it only enables RxRTS but in this context I need TxRTS and I added some similar code to enable TxRTS. I also give power it and made proper pin multiplexing. 

I added nothing more then these and try to run example codes. I obtain only [00] for every send operation in terminal. 

Ps. KE18F has only UART0 and UART1 but TWR-IND-IO uses UART2 for RS485. Therefore I connected manually corresponding pins to UART1 to UART2 (Tx, Rx, RTS). 

I am stucked here and really appreciate any help.

Onur

4 Replies

313 Views
onurdemirel
Contributor III

Hello,

There are some good news about this issue. I want to inform this post about.

The main problem was about my cable material and it has some problem, when I change the connection cables it starts to give consistent output. One more problem was ISO1176 uses A(+) B(-) notation but default RS485 notation is like B(+) A(-). When I switch A and B connections I obtain correct transmission. 

I could transmit data by giving high via GPIO to RTS pin. I couldn't work the internal TxRTS property enabled from MODIR register. 

The remaining problem is with reading data. When I connect low to RTS pin it should done read operation. It is okay but I think there are some FIFO mechanism that saves sent data to recieve fifo and in the result I read back only the first 4 byte of the sent data.

Thanks in advance,

Onur

0 Kudos

313 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Onur,

    Thanks a lot for your updated information.

     Actually, the KE1X LPUART already support the hardware flow control for RTS and CTS signals. But you use the GPIO to control the RTS, it's also OK.

     When you receive the data, you need to pull RTS to low, RTS normally connect to the CTS to your slave device, then it means the master can receive the data, the slave will send the data. In your master side, you just need to use the UART to receive the data is OK, if your FIFO is full, you can pull the RTS to high, it means, you don't need to receive the data any more. If your receive have problems, you can refer to our offical uart receive code, actually, you just need to add the RTS control, and CTS control function. Actually, when you finish the reading data, then you pull RTS to low, it is controlled by yourself.  If you don't enable the LOOPS in the CTRL register, the send data won't back to the read fifo.

     So, I think you can check your UART receive function at first, after it works, then you add the RTS control again.

Wish it helps  you!

If you still have question about it, please kindly let me know.

   


Have a great day,
Kerry

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

313 Views
onurdemirel
Contributor III

Hi Kerry,

Thanks for your explanatory answer.

I solve this issue by flushing the RX FIFO before I read from UART.

I still couldn't figure out internal RTS pin and usage but I use GPIO pin for this problem and arrange timing of Low and High by waiting for Transmission Complete Flag. 

Now there is no problem for me, thanks for your help.

Have a nice day,

Onur

0 Kudos

313 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Onur,

   That's very good to hear your problem is solved!

   If GPIO have no problem, you totally can use the GPIO, it will be more flexible.

   If you have the new question in the future, welcome to let us know.

  About this post, please mark the correct the answer, just to close this post, thank you!


Have a great day,
Kerry

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

0 Kudos