Terminal Hardware Handshaking

This section consists of notes I’ve made whilst looking at adding hardware handshaking to my STM32F0 Discovery board and is a work in progress at the moment.

RTS/CTS uses the pins RTS and CTS on the serial connector. * RTS means “Request To Send”. When this pin stays asserted (positive voltage) at the receiver it means: keep sending data to me. * If RTS is negated (voltage goes negative) it negates “Request To Send” which means: request not to send to me (stop sending). * When the receiver is ready for more input, it asserts RTS requesting the other side to resume sending.

  • For computers and terminals (both DTE type equipment) the RTS pin sends the flow control signal to the CTS pin (Clear To Send) on the other end of the cable. That is, the RTS pin on one end of the cable is connected to the CTS pin at the other end.

Hardware

  • STM32F0 Discovery (Disco) Board

Option 1

  • $25 FTDI usb serial cable with RX, TX, GND, 5V DC supply and nCTS and nRTS signals on a 6 pin connector. FT232RQ chip is used. USB Vendor ID (VID): 0403h, USB Product UD (PID): 6001h . Note TX and RX have a internal 270R resistor.
signal color
+5v Red
Ground Black
TX Orange (output)
RX Yellow (input)
CTS Brown (input)
RTS Green (output)
signal color Disco Pins
+5v Red +5v
Ground Black GND
TX Orange PA-10
RX Yellow PA-9
nCTS Brown PA-12
nRTS Green PA-11
_images/cbl-usb-rs232-3.3v.jpg

Option 2

  • $1 cheap Unix friendly PL2303 chipset usn 3.3v serial dongle (usb3.3v-dongle), but nCTS and nRTS wires will need to be soldered onto the PL2303 28 pin SSOP28 chip used in the dongle.
_images/usb-3_3v-serial-dongle.jpg

Modifying the usb3.3v-dongle

The following control lines are needed

PL2303 28 pin SSOP28 Package

signal pl2303 pin disco board
nDTR 2  
nDSR 9  
nDCD 10  
nCTS 11 <–  
nRTS 3 –>  

STM32F0 discovery board

Handshaking Timing

_images/stm32f0-rts-cts-timing2.jpg

Code

  • USART1
The following pins are required in Hardware flow control mode:
  • nCTS: Clear To Send blocks the data transmission at the end of the current transfer when high
  • nRTS: Request to send indicates that the USART is ready to receive data (when low).
\ Hardware flow control

|--------------+-----------------------+-------------------|
| STM32F0 Pin  | Flow control Function | ALT Configuration |
|--------------+-----------------------+-------------------|
| PA12         | USART1_RTS            | AF1               |
| PA11         | USART1_CTS            | Al1               |
| PA9          | USART1_TX             | Al1               |
| PA10         | USART1_RX             | Al1               |
|--------------+-----------------------+-------------------|


$4004A000 constant PORTB_PCR
$4006A015 constant UART0_RWFIFO

: ctsrts-pin-init ( -- ) \ Note: this is now done in the mecrisp core
$0300  2 4 * PORTB_PCR + ! \ Port B GPIO (Alternative 3)
$0300  3 4 * PORTB_PCR + ! \ Port B GPIO (Alternative 3)
;

: cts-enable   %1 uart0_modem cbis! ;
: rts-enable %1000 uart0_modem cbis! ; \ Note:  this is now done mecrisp core

\ UART0_MODEM
\ Bit #3 RXRTSE
\ Receiver request-to-send enable
\ Allows the RTS output to control the CTS input of the transmitting device to prevent receiver overrun.
\ NOTE: Do not set both RXRTSE and TXRTSE.
\ 0 The receiver has no effect on RTS.
\ 1 RTS is deasserted if the number of characters in the receiver data register (FIFO) is equal to or greater than RWFIFO
[RXWATER]. RTS is asserted when the number of characters in the receiver data register (FIFO) is less than RWFIFO[RXWATER
].

Table Of Contents

Previous topic

Connecting a Serial Terminal

Next topic

Words

This Page