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

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Jump to solution
17,957 Views
marcocavallini
Contributor IV

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
4,602 Views
marcocavallini
Contributor IV

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
8 Replies
1,289 Views
Kanstantsin
Contributor I

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
1,281 Views
igorpadykov
NXP TechSupport
NXP TechSupport

right

 

Best regards
igor

4,603 Views
marcocavallini
Contributor IV

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
4,602 Views
marcocavallini
Contributor IV

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
4,602 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
4,602 Views
marcocavallini
Contributor IV

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

4,602 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
4,602 Views
marcocavallini
Contributor IV

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.