Cornell University ECE4760
UART serial

Serial Communication

The UART is used for comunication of serial data. You can use it between two PIC32 processors, or from a PIC32 to a PC using a UART-USB COM port adaptor. It is even possible to use it in an address mode to communicate across several PIC32s. The UART supports TTL-level RS232, considered a legacy interface, but simple and useful. The UART transmit block diagram shows that there is a small FIFO buffer and a serializer. The serial bits are shown below. It takes 10 bit-times to send 8 bits. The UART receive block diagram shows a small FIFO and a de-serializer. The incoming waveform is sampled three times/bit for error detection.  To connect two PIC32s, cross-wire TX and RX as shown below.

In addition to the standard 8-bit mode, there is a 9-bit address mode that allows several devices to share TTL-level UART signals. A typical multi-processor communication protoc ol differentiates between data bytes and address/control bytes. A common scheme is to use a 9th data bit to identify whether a data byte is address or data information. If the 9th bit is set, the data is processed as address or control information. If the 9th bit is cleared, the receiv ed data word is processed as data associated with the previous address/control byte. The protocol operates in the following sequence:

-- The master device transmits a data word with the 9th bit set. The data word contains the address of a slave device and is considered the address word.
-- All slave devices in the communication chain receive the address word and check the slave address value
-- The slave device that is specified by the address word receives and processes subsequent data bytes sent by the master device. All other slave devices discard subsequent data bytes until a new address word is received.

Connections for multiple devices might look like the following:


ProtoThreads support

The ProtoThreads 1_2_2 has support for using the UART communication to a PC. See the ProtoThreads page for information on using the UART as a console. The XC32 compiler defaults to using UART2 as the default serial target for putchar and getchar. The ProtoThreads 1_2_2 header assigns U2RX to RA1 and U2TX to RB10. The header also defines non-blocking transmit and receive routines for the UART. The BAUD rate is set in config_1_2_2.h.

On the PC side there will be a USB connection for serial communication between the running program and the PC, which will be running PuTTY. Set up PuTTY for 9600 baud, no parity, 1 stop-bit, no flow-control. In the PuTTY config window, choose serial connection, then click serial in the left hand panel and set the parameters. Connect PuTTY to whatever serial port the USB connection configures. Use Control Panel...System...Hardware Tab...Device Manager Button...+Ports to find out which serial port is connected to the USB connection.

UART to USB Adafruit serial cable:


The blue serial-USB connection is a USB cable with embedded USB/serial bridge chip with 3.3 volt logic levels.
-- Use wires to connect the the three signals below. 
-- Do NOT connect USB Vcc (red wire) to anything
, unless you need 5 volt power for a circuit not associated with the MCU.
-- Connect UART receive pin (U2RX)  to the green wire (default to RA1 on big board)
-- Connect UART transmit pin (U2TX) to white wire (default to RB10 on big board)
-- Connect MCU ground to black wire

Copyright Cornell University November 2, 2017