Add RTS and CTS in SAMA5D27

Moderator: nferre

punchingkan
Posts: 12
Joined: Thu Mar 01, 2018 11:59 am

Add RTS and CTS in SAMA5D27

Sat Apr 21, 2018 9:42 am

Hii

I am using SAMA5D27-SOM1-Ek with demo poky-linux image. What should i include in device tree file to have rts and cts pins for ttyS1.

Thank You
Punchingkan
blue_z
Location: USA
Posts: 1677
Joined: Thu Apr 19, 2007 10:15 pm

Re: Add RTS and CTS in SAMA5D27

Sun Apr 22, 2018 2:38 am

punchingkan wrote:What should i include in device tree file to have rts and cts pins for ttyS1.
The Device Tree file at91-sama5d27_som1_ek_common.dtsi assigns uart4 to serial1, which would map to /dev/ttyS1.
The Atmel/Microchip UART devices typically do not support hardware flow control (i.e. RTS and CTS pins), whereas the USART and FLEXCOM devices do.

Regards
punchingkan
Posts: 12
Joined: Thu Mar 01, 2018 11:59 am

Re: Add RTS and CTS in SAMA5D27

Thu May 03, 2018 6:11 pm

Thank you bluez, i want use flexcom3 and made following changes to default at91-sama5d27_som1_ek_common.dtsi file

disabled ISC to avoid conflict

flx3: flexcom@fc014000 {
atmel,flexcom-mode = <ATMEL_FLEXCOM_MODE_USART>;
status = "okay";

uart7: serial@200 {
compatible = "atmel,at91sam9260-usart";
reg = <0x200 0x200>;
interrupts = <22 IRQ_TYPE_LEVEL_HIGH 7>;
clocks = <&flx3_clk>;
clock-names = "usart";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_flx3_default>;
atmel,fifo-size = <32>;
status = "okay"; /* Conflict with isc. */
};

spi2: spi@400 {
compatible = "atmel,at91rm9200-spi";
reg = <0x400 0x200>;
interrupts = <22 IRQ_TYPE_LEVEL_HIGH 7>;
clocks = <&flx3_clk>;
clock-names = "spi_clk";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_flx3_default>;
atmel,fifo-size = <16>;
status = "disabled"; /* Conflict with isc. */
};
};




pinctrl_flx3_default: flx3_default {
pinmux = <PIN_PC20__FLEXCOM3_IO0>,
<PIN_PC19__FLEXCOM3_IO1>,
<PIN_PC18__FLEXCOM3_IO2>,
<PIN_PC21__FLEXCOM3_IO3>,
<PIN_PC22__FLEXCOM3_IO4>;
bias-disable;
};
But only rx,tx are working, rts() and cts are not working. What else should i do to make rts and cts work.

Thank You
Punchingkan
blue_z
Location: USA
Posts: 1677
Joined: Thu Apr 19, 2007 10:15 pm

Re: Add RTS and CTS in SAMA5D27

Thu May 03, 2018 11:38 pm

punchingkan wrote:But only rx,tx are working, rts() and cts are not working. What else should i do to make rts and cts work.
The Device Tree is used by the kernel to associate device drivers to hardware, and assign pins to devices.
The actual use of RS-232 hardware flowcontrol is optional, and therefore needs to be enabled (in userspace).
Use the CRTSCTS flag in the c_cflag member of the termios structure to enable/disable hardware flowcontrol.

Code: Select all

    sfd = open("/dev/ttyS3", O_RDWR | O_NOCTTY);
    if (sfd < 0) {
        /* handle error */
    }

    rc = tcgetattr(sfd, &tty);
    if (rc < 0) {
        /* handle error */
    }
    spd = B115200;
    cfsetospeed(&tty, (speed_t)spd);
    cfsetispeed(&tty, (speed_t)spd);

    cfmakeraw(&tty);    /* non-canonical mode */
    tty.c_cc[VMIN] = 1;
    tty.c_cc[VTIME] = 10;

    tty.c_cflag &= ~CSTOPB;
    tty.c_cflag |= CRTSCTS;    /* enable HW flowcontrol */
    tty.c_cflag |= CLOCAL | CREAD;

    rc = tcsetattr(sfd, TCSANOW, &tty);
    if (rc < 0) {
        /* handle error */
    }

Refer to the man page for termios and Serial Programming Guide for POSIX Operating Systems for details.


Regards
punchingkan
Posts: 12
Joined: Thu Mar 01, 2018 11:59 am

Re: Add RTS and CTS in SAMA5D27

Tue May 08, 2018 6:44 pm

Thank you BlueZ

Rts and Cts are working now, If I use baud rates more than 115200, it is receiving garbage data while transmitter is working great at all baud rates. I triple checked using a logic analyser, the problem is in the sama5d2 receiver end. Please suggest a work around.

Thank you
Punchingkan
blue_z
Location: USA
Posts: 1677
Joined: Thu Apr 19, 2007 10:15 pm

Re: Add RTS and CTS in SAMA5D27

Wed May 09, 2018 2:34 am

punchingkan wrote:If I use baud rates more than 115200, it is receiving garbage data
You haven't provided sufficient information to offer advice.
What is generating the RXD signal? How long is the TTL wire? Are RS-232 transceivers or USB adapters involved?
Have you measured the baud rate error?

Regards
punchingkan
Posts: 12
Joined: Thu Mar 01, 2018 11:59 am

Re: Add RTS and CTS in SAMA5D27

Fri May 11, 2018 1:17 pm

rx signal is transmitted by TI's wl1837mod, wire is 15cm long and no RS-232 transceivers or USB adapters involved.
I should receive 4 14 12 1 1 16 0 6 0 0 6 13 0 144 27 ( 0x4 0xe 0xc 0x1 0x1 0x10 0x0 0x6 0x0 0x0 0x6 0xd 0x0 0x90 0x1b ) bytes as response for 1 1 16 0 ( 0x01 0x01 0x10 0x00 ) command.

4 14 12 1 1 16 0 6 0 0 6 13 0 144 27 is the expected response,
response came in multiple trials
4 14 12 1 1 00 0 6 0 0 6 13 0 144 27
4 14 12 1 1 00 0 6 0 0 6 13 0 144 27
4 14 12 1 1 16 0 6 0 0 6 13 0 144 27
4 14 12 1 1 00 0 6 0 0 6 13 0 144 27
4 14 12 1 1 16 0 6 0 0 6 13 0 016 27
4 14 12 1 1 16 0 6 0 0 6 13 0 144 27
4 14 12 1 1 16 0 6 0 0 6 13 0 128 27
4 14 12 1 1 16 0 6 0 0 6 13 0 144 27
4 14 12 1 1 16 0 6 0 0 6 13 0 144 27
4 14 12 1 1 16 0 6 0 0 6 13 0 144 27
4 14 12 1 1 16 0 6 0 0 6 13 0 144 27
4 14 12 1 1 16 0 6 0 0 6 13 0 144 27
4 14 12 1 1 16 0 6 0 0 6 13 0 144 27
4 14 12 1 1 16 0 6 0 0 6 13 0 144 27
4 14 12 1 1 16 0 6 0 0 6 13 0 144 27
4 14 12 1 1 16 0 6 0 0 6 13 0 016 27
4 14 12 1 1 16 0 6 0 0 6 13 0 144 27
4 14 12 1 0 16 0 6 0 0 6 13 0 144 27
4 14 12 1 1 00 0 6 0 0 6 13 0 144 27
4 14 12 1 1 00 0 6 0 0 6 13 0 144 27
4 14 12 1 1 16 0 6 0 0 6 13 0 144 27
4 14 12 1 1 16 0 6 0 0 6 13 0 144 19
4 14 12 1 1 16 0 6 0 0 6 13 0 144 27
4 14 12 1 1 00 0 6 0 0 6 13 0 144 27
4 14 12 1 1 16 0 6 0 0 6 13 0 144 27
4 14 12 1 1 16 0 6 0 0 6 13 0 144 27
4 14 12 1 1 00 0 6 0 0 6 13 0 016 27
4 14 12 1 1 00 0 6 0 0 6 13 0 016 27
4 14 12 1 1 16 0 4 0 0 6 13 0 144 27
4 14 12 1 1 00 0 6 0 0 6 13 0 016 27
4 14 12 1 1 16 0 6 0 0 6 13 0 144 27

Thank You
Punchingkan
blue_z
Location: USA
Posts: 1677
Joined: Thu Apr 19, 2007 10:15 pm

Re: Add RTS and CTS in SAMA5D27

Mon May 14, 2018 8:46 pm

Your characterization of "receiving garbage data" seems to reflect no attempt of analysis. Comparison of decimal data instead of binary/hex does not help.

The data has occasional bit flips. Specific bytes in the message are more prone than others.

punchingkan wrote:Please suggest a work around.
Use a baudrate that doesn't cause errors.

Regards

Return to “SAMA5-based”

Who is online

Users browsing this forum: No registered users and 5 guests