i.MX6: how to use RTS/CTS properly using UART (DTE/DCE)

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

i.MX6: how to use RTS/CTS properly using UART (DTE/DCE)

Jump to solution
30,548 Views
marcocavallini
Contributor V

I have read a lot of posts in this community and on the internet

and the datasheet but I'm still confused about the RTS/CTS management with i.MX6.

Looks line any board is supporting these signals properly nor anybody really cares about them,

so I wonder if someone out there has experienced and solved this problem.

https://community.freescale.com/docs/DOC-97509

I need to reproduce the behaviour I have connecting two PCs with a

Loopback handshaking null modem cable

https://en.wikipedia.org/wiki/Null_modem#Loopback_handshaking

If I use 2 PCs I see RTS low during the transmission of data on TX

Using an i.MX6 UART3 (/dev/ttymxc2) configured in the Device Tree as follows

I get this 2 different behaviours depending on the "fsl,dte-mode" only.

TX and RTS are normally low

If I set "fsl,dte-mode" I see RTS going high during a period of time similar to the trasmission of data

but there is no data exiting out on TX

If I comment (unset) "fsl,dte-mode" I see data exiting out on TX

but RTS is always low not moving and not handshaking data.

Would be possible to use RTS/CTS like a PC does?

I tested this with linux kernel 3.14.28 and 4.1.15 without success.

pinctrl_uart3_mh: uart3grp-mh {

    fsl,pins = <

        MX6QDL_PAD_EIM_D25__UART3_RX_DATA 0x1b0b1

        MX6QDL_PAD_EIM_D24__UART3_TX_DATA 0x1b0b1

        MX6QDL_PAD_EIM_D23__UART3_CTS_B   0x1b0b1

        MX6QDL_PAD_EIM_D31__UART3_RTS_B   0x1b0b1

    >;

};

       

&uart3 {            // /dev/ttymxc2

    pinctrl-names = "default";

    pinctrl-0 = <&pinctrl_uart3_mh>;

    fsl,uart-has-rtscts;

    fsl,dte-mode;

    status = "okay";

};

Any hint would be greatly appreciated.

TIA

1 Solution
17,193 Views
marcocavallini
Contributor V

At last I understood the behaviour and solved the problem.

This post explains everything perfectly: https://community.freescale.com/docs/DOC-97509

Be careful: dte-mode swaps RTS/CTS and TX/RX pins

View solution in original post

0 Kudos
14 Replies
9,558 Views
piyyamperumal
Contributor I

Anyone really solved this issue with the above device tree along above device tree? I see its solved but looks like there is no solution provided. 

0 Kudos
9,544 Views
Kanstantsin1
Contributor III

Hi there. There is no possibility to swap RX<=>TX without swapping CTS<=>RTS.

You can swap RX <=> TX if  you don't use CTS and RTS easily.

If you use  TX/RX and CTS/RTS - and want to то swap only one of them => you must do  it in hardware. 

0 Kudos
9,534 Views
piyyamperumal
Contributor I

Hi 

Thanks for responding. 

We had a mistake in our board, RX &TX, CTS & RTS are connected 1 to 1 directly to the device from iMX8, and below is the existing Hardware connection done on our board. It's impossible to do the hardware reworked to swap these signals. Instead, I would like to swap inside the IO Port and IOMUX. 

Existing UART Connections Between iMX8 & BT Device
UART IP port, InternalIO DirectioniMX8 PIN OUT Device Side Signals & Pins Connected
RTS_BIUART_RTS_B UART_RTS
CTS_BOUART_CTS_B UART_CTS
RXDIUART_RXD UART_RXD
TXDOUART_TXD UART_TXD
     

I have updated the device tree with the like below and I am trying to use UART3 in DTE mode. 

New UART Swap within the iMX8 and BT Device connection

DTE Mode (DCEDTE=1)   
UART IP port, InternalIO DirectioniMX8 PIN OUT Device Side Signals & Pins Connected
RTS_BIUART_CTS_B UART_RTS
CTS_BOUART_RTS_B UART_CTS
RXDIUART_TXD UART_RXD
TXDOUART_RXD UART_TXD

 

Can someone explain, WIll this New IOMUX swap work with the device connected?

How do we set UARTxUFCR[DTEDCE] bit? Is it the same as "fsl,dte-mode"set"?

I also followed this link to read about Swapping in the IOMUX and the possible solution I could See. but I couldn't see any transaction on the TX/RX signals?

 

Can someone provide me the link to this solution, As this is saying solved? 

 

Thanks,

Peri

 

0 Kudos
9,518 Views
Kanstantsin1
Contributor III

Hi.

1. I am not sure that IMX8 has the same problem with uart as imx6.

2. You can try next:  not use CTS/RTS from uart. Use them as GPIO and set high level  to enable transmit  from other side. Some of devices perfectly work on speeds up to 115200.

28 Views
sfatyushkin
Contributor I

Thanks a lot!
I read several threads about this problem (replacing RTS/CTS in the documentation from NXP regarding the standard description of these lines) - many developers made such a mistake (I made one too). And this solution (declaring them GPIO and setting static levels) really works (tested on IMX8).
It would be nice if NXP included this solution in the documentation.

Best regards,

0 Kudos
13,880 Views
Kanstantsin
Contributor II

Hi there. I have digged around of the topic.

I would like to finish this topic with one clear though: There is no possibility to swap RX<=>TX without swapping CTS<=>RTS.

@igorpadykov Is it right?  

0 Kudos
13,872 Views
igorpadykov
NXP Employee
NXP Employee

right

 

Best regards
igor

17,194 Views
marcocavallini
Contributor V

At last I understood the behaviour and solved the problem.

This post explains everything perfectly: https://community.freescale.com/docs/DOC-97509

Be careful: dte-mode swaps RTS/CTS and TX/RX pins

0 Kudos
17,193 Views
marcocavallini
Contributor V

In addition I'm attaching the excerpt from NXP documentation

iMX6-UART-DTE-DCE.png

Marco Cavallini | KOAN sas | Bergamo - Italia
embedded software engineering
https://KoanSoftware.com

0 Kudos
17,194 Views
madisox
Contributor III

It took several iterations on both the i.MX6 side and the other, but eventually we did get CTS/RTS working on our 6Q custom board.  We're using the default DCE mode for the UART.  We set the "fsl,uart-has-rtscts" property on the uart in the device tree for the driver to make use of the pins, and use the "stty -F /dev/ttymxc<n> crtscts" command to turn it on.

0 Kudos
17,194 Views
marcocavallini
Contributor V

Thank you madisox,

During my tests I use minicom, so the Hardware Flow Control is activated like you did with "stty -F /dev/ttymxc<n> crtscts" command.

I can't use the default DCE mode for the UART because I need that the RTS signal operated like with PC, so normally high and gets low when I want to TX.

The huge problem here is that if I enable dte-mode in the DeviceTree I don't have any data out on the TX line (even though I connect RTS to CTS to enable transmission), and I wonder if this is a silicon bug or a lack in the imx.c driver.

Any further help would be greatly appreciated.

TIA

3,634 Views
adamhuang
Contributor III

Thanks Macro Cavallini

0 Kudos
17,194 Views
weidong_sun
NXP TechSupport
NXP TechSupport

Hello Marco

    Yes, we are often confused about these 2 concepts on UART port. Let me give you my explanation to you :

DCE side: provide clock to other side(DTE). In the mode, CTS is OUTPUT, RTS is INPUT.

DTE side:  working with clock from DCT.      In the mode, CTS is INPUT, RTS is OUTPUT.

Gernerally speaking, before you connect one device to the other, you only need to confirm CTS & RTS directions of UART for 2 devices. For example, connecting UART of I.MX6 to that of PC.

PC( usually, DTE device): PC_UART_CTS ----INPUT; PC_UART_RTS---OUTPUT.

I.MX6(using DCE mode);  MX6_UART_CTS---OUTPUT; MX6_UART_RTS--INPUT.

Connect 2 devices together:

PC_UART_CTS-------MX6_UART_CTS

PC_UART_RTS-------MX6_UART_RTS

But if you set I.MX6 UART DTE mode, it means:

I.MX6(using DTE mode);  MX6_UART_CTS---INPUT; MX6_UART_RTS--OUTPUT.

conections will be changed:

PC_UART_CTS-------MX6_UART_RTS

PC_UART_RTS-------MX6_UART_CTS

You only need to ensure signal directions are correct !

Hope above explanation can help you !

Regards,

Weidong

0 Kudos
17,194 Views
marcocavallini
Contributor V

Hi Weidong,

thank you for answering.

I tried doing the way you told me, but I can't see any change.

I measured the signals TX,RX,RTS,CTS with a scope directly on the CPU pin (TTL) before the TTL-RS232 converter (I removed it)

The signals operate in the same manner and I didn't notice any swap on their behaviour.

The result of my test is that if I enable dte-mode in the DeviceTree I don't have any data out on the TX line

This is what I see transmitting a single char using minicom with a PC

When I use the iMX6 based board (/dev/ttymxc2) the RTS line is the same (high) but TX is always low and no data exit out.

uart-rtscts.png

I tried these settings

// DCE mode : standard

MX6QDL_PAD_EIM_D25__UART3_RX_DATA 0x1b0b1

MX6QDL_PAD_EIM_D24__UART3_TX_DATA 0x1b0b1

MX6QDL_PAD_EIM_D23__UART3_CTS_B   0x1b0b1

MX6QDL_PAD_EIM_D31__UART3_RTS_B   0x1b0b1

// DTE mode : requires fsl,dte-mode; (RTS/CTS inverted)

MX6QDL_PAD_EIM_D25__UART3_RX_DATA 0x1b0b1

MX6QDL_PAD_EIM_D24__UART3_TX_DATA 0x1b0b1

MX6QDL_PAD_EIM_D23__UART3_RTS_B   0x1b0b1

MX6QDL_PAD_EIM_D31__UART3_CTS_B   0x1b0b1

// DTE mode : requires fsl,dte-mode; (all inverted)

MX6QDL_PAD_EIM_D25__UART3_TX_DATA 0x1b0b1   

MX6QDL_PAD_EIM_D24__UART3_RX_DATA 0x1b0b1

MX6QDL_PAD_EIM_D23__UART3_RTS_B   0x1b0b1

MX6QDL_PAD_EIM_D31__UART3_CTS_B   0x1b0b1

I'm even more confused.