Skip to content

Hardware Flow Control for Serial, Serial2

bombasticbob edited this page Dec 12, 2014 · 3 revisions

Hardware Flow Control

In order to accomodate a form of hardware flow control, the current implementation uses macros in the 'pins_arduino.h' to declare which pin(s) will be used for what flow control purpose.

The macros are set up as follows:

  • SERIAL_n_RTS_PORT_NAME - the port name for the 'RTS' (aka 'DTR') output
    This will connect to the CTS input for the sending serial port. It is active low. A high output tells the sender to stop sending.
  • SERIAL_n_RTS_PIN_INDEX - the 'pin index' (0 through 7) on the port specified by 'SERIAL_n_RTS_PORT_NAME'
  • SERIAL_n_CTS_PORT_NAME - the port name for the 'CTS' input ('DTR' out for sender)
    This will connect to the 'CTS' out (aka 'DTR') on the receiving serial port. It is active low. A high input tells the XMega firmware to stop sending.
    CTS high to low transition causes an interrupt that may result in serial I/O (for faster response times).
  • SERIAL_n_CTS_PIN_INDEX - the 'pin index' (0 through 7) on the port specified by 'SERIAL_n_CTS_PORT_NAME'.

Typical usage:
// RTS(DTR) on port D pin 0
#define SERIAL_0_RTS_PORT_NAME PORTD
#define SERIAL_0_RTS_PIN_INDEX 0

// CTS on port D pin 1
#define SERIAL_0_CTS_PORT_NAME PORTD
#define SERIAL_0_CTS_PIN_INDEX 1