Sharvin
Posts: 17
Joined: Tue Feb 19, 2019 1:19 pm

How to enable CTS RTS for Raspberry Pi 3 b+ UART

Wed May 29, 2019 11:03 am

I have a Raspberry Pi 3 b+ with Raspbian Stretch Lite. I want to enable CTS RTS for UART ttySO.

To achieve this I have followed the following steps:-

1. I have enabled the UART ( Note I have tested the UART and it is working perfectly. ) I have configured UART using this link
https://www.circuits.dk/setup-raspberry-pi-3-gpio-uart/

2. I searched for a document to enable CTS RTS for Raspberry Pi. I am unable to find any relevant source to solve this issue.

Can anyone please share a document or any resource so I can enable CTS RTS on UART ttySO?.

User avatar
joan
Posts: 15043
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: How to enable CTS RTS for Raspberry Pi 3 b+ UART

Wed May 29, 2019 12:21 pm

At the very least you will have to enable the CTS and RTS GPIO. You will then have to connect those GPIO to the external device.

CTS is available on GPIO16.

RTS is available on GPIO17.

For UART 0 (I guess ttyS0) you will have to place those GPIO in mode ALT3. For UART 1 you will have to place those GPIO in mode ALT5.

See page 102 of BCM2835 ARM Peripherals

I don't know if the kernel driver will then automatically handle CTS/RTS. You will have to try.

HiassofT
Posts: 307
Joined: Fri Jun 30, 2017 10:07 pm
Location: Salzburg, Austria
Contact: Website

Re: How to enable CTS RTS for Raspberry Pi 3 b+ UART

Wed May 29, 2019 12:24 pm

You can do this with a small, custom device tree overlay file.

A couple of months ago I faced the same issue and created a bunch of overlays - you can download them from here https://github.com/HiassofT/AtariSIO/tr ... ontrib/rpi

For ttyS0 you need to copy "miniuart-ctsrts.dtbo" to /boot/overlays and then enable it with "dtoverlay=miniuart-ctsrts" in config.txt

so long,

Hias

Sharvin
Posts: 17
Joined: Tue Feb 19, 2019 1:19 pm

Re: How to enable CTS RTS for Raspberry Pi 3 b+ UART

Wed May 29, 2019 2:19 pm

Thanks a lot it worked
HiassofT wrote:
Wed May 29, 2019 12:24 pm
You can do this with a small, custom device tree overlay file.

A couple of months ago I faced the same issue and created a bunch of overlays - you can download them from here https://github.com/HiassofT/AtariSIO/tr ... ontrib/rpi

For ttyS0 you need to copy "miniuart-ctsrts.dtbo" to /boot/overlays and then enable it with "dtoverlay=miniuart-ctsrts" in config.txt

so long,

Hias

shivpatil
Posts: 3
Joined: Tue May 28, 2019 5:54 am
Location: India

Re: How to enable CTS RTS for Raspberry Pi 3 b+ UART

Fri May 31, 2019 1:44 pm

Hello,

I getting the same problem while Communicating with a device using UART Interface using HW Flow Control Enabled.

I have done the following settings
1. Added following lines @end if /boot/config.txt file.
enable_uart=1
dtoverlay=pi3-disable-bt
dtoverlay=miniuart-ctsrts

2. Added "miniuart-ctsrts.dtbo" to /boot/overlays.


I would like to ask that,

I Have to use MAIN UART (PL011) of the Raspberry Pi rather than MINI UART to achive a higher baud rate (1500000) & more stability (as mini uart has some drawbacks like not able to detect breakdown, no receive timer interrupts etc).

For that I have disabled the Bluetooth UART Port.



Out of serial0 & serial1 which one is configured for Bluetooth?

Will this Configurations enables the CTS/RTS Pins for MAIN UART (PL011) ?

If I would also like to enable CTS RTS for that UART what should I do?..

HiassofT
Posts: 307
Joined: Fri Jun 30, 2017 10:07 pm
Location: Salzburg, Austria
Contact: Website

Re: How to enable CTS RTS for Raspberry Pi 3 b+ UART

Sat Jun 01, 2019 9:39 am

For the PL011 (/dev/ttyAMA0) UART use the uart-ctsrts overlay from the github link I posted above.

so long,

Hias

gerrieCreatron
Posts: 1
Joined: Sun Feb 16, 2020 6:46 pm

Re: How to enable CTS RTS for Raspberry Pi 3 b+ UART

Sun Feb 16, 2020 7:44 pm

RaspberryPi 3B+ , The following have been done :

1. sudo raspi-config
Select option 5, Interfacing options, then option P6, Serial, and select No. Exit raspi-config.

2. /boot/config.txt
add the following

dtoverlay=gpio-shutdown,gpio_pin=5,active_low=1,gpio_pull=up
dtparam=act_led_gpio=4
enable_uart=1
dtoverlay=miniuart_bt
dtoverlay=uart-ctsrts

3. Added following files to /boot/overlays from https://github.com/HiassofT/AtariSIO/bl ... ntrib/rpi/
uart-ctsrts.dtbo

4. Connected GPIO17 to GPIO16 with hardware link (CTS/RTS)

5. Scope on CTS/RTS .. nothing happens if I use minicom on /dev/ttyAMA0, tested with both setups: No/Yes hardware handshaking.
Minicom does however send characters.

6. I tried stty -F /dev/ttyAMA0 crtscts , but no error nor toggling RTS output.

7. I Need RST to set RS485 Driver direction via NOT gate to transmit/receive.

boot# dmesg | grep tty
[ 0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=1 bcm2708_fb.fbwidth=1680 bcm2708_fb.fbheight=1050 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=18d8f574-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
[ 0.000907] console [tty1] enabled
[ 1.067553] 3f201000.serial: ttyAMA0 at MMIO 0x3f201000 (irq = 81, base_baud = 0) is a PL011 rev2
[ 1.076610] 3f215040.serial: ttyS0 at MMIO 0x0 (irq = 53, base_baud = 50000000) is a 16550


What am I doing wrong ?

Do you need IOCTL command to toggle the RTS or will it happens automatically ?

Return to “Interfacing (DSI, CSI, I2C, etc.)”