More on Raspberry Pi serial ports

23rd Monday, 2012  |  Engineering News, Life at LAVA  |  no comments

This blog posting on the Raspberry Pi serial ports goes into a bit more detail than the last post on Raspberry PI serial interfacing, as it compares the two serial ports the Raspberry Pi has and looks more closely at the characteristics of the second serial port available on the Raspberry Pi.

Of course, for those intending to use the Raspberry Pi as an embedded SBC more serial ports might be desirable. In that case, they could be added using the USB connector and and USB-to-serial adapter.

However, the Raspberry Pi has serial ports of its own. The first serial port, the “Mini UART,” was discussed in the last Raspberry Pi blog post, and it can basically be seen as a console port for access to the Raspberry Pi.

The second serial port is a more fully-implemented version of the 16C550/16C650, with more hardware lines available and with greater configurability for buffers and flow control. It is a version of the ARM PrimeCell PL011 UART. The details of the two ports are shown in the following table:

Raspberry Pi serial ports compared

Mini UART

Raspberry Pi PL011 UART

intended use

console port

general RS-232 interfacing

location

GPIO pin header (pins shown in previous Raspberry Pi blog post)

GPIO pin header (pins shown below)

baud

baudrate derived from system clock

baud rate generation, dc up to UARTCLK/16 (programmable)

bits

7 or 8 bit operation

5, 6, 7, or 8 bits

start & stop bits

1 start bit 1 stop bit

1 or 2 stop bit generation

parity

no parities

start, stop and parity (standard asynchronous)

even, odd, stick, or no-parity bit generation and detection

interrupts

no receive timeout interrupt; break generation

break generation

buffers

8 symbols deep FIFOs for receive and transmit

separate 16×8 transmit and 16×12 receive FIFO

control signals

s/w controlled RTC, s/w readable CTS

support of the modem control functions CTS and RTS

flow control

auto flow control with programmable FIFO level

programmable hardware flow control.

register structure

16550-like registers

16550-like registers

no break detection, no framing errors detection

line break generation and detection; false start bit detection

excluded signals

no DCD, DSR, DTR, or RI signals

DCD, DSR, DTR, and RI are not supported

The PL011 UART varies from the industry-standard 16C650 UART device as follows:

•   Receive FIFO trigger levels are 1/8, 1/4, 1/2, 3/4, and 7/8
•  Transmit FIFO trigger levels are 1/8, 1/4, 1/2, 3/4, and 7/8
•  The internal register map address space, and the bit function of each register differ
• The deltas of the modem status signals are not available.

The following 16C650 UART features are not supported:
•  1.5 stop bits (1 or 2 stop bits only are supported)
•   Independent receive clock.

The following functionality of the ARM PrimeCell UART (PL011) is not supported in the Raspberry Pi implementation:
•  Infrared Data Association (IrDA)
•  Serial InfraRed (SIR) protocol Encoder/Decoder (ENDEC)
• Direct Memory Access (DMA).

In most applications these differences will not matter, as the largest part of serial peripherals do not use all the signalling implemented on full-blown serial ports.

GPIO voltages

Hooking up a serial port on the Raspberry Pi’s GPIO has one complication that needs to be borne in mind: the voltages on the GPIO pins are not in the range of those required for conventional RS-232, RS-422, or RS-485. Specifically, the GPIO pins supply “logic level” signalling, at about 0v to 3.3v.

Since RS-232 looks for levels of -5v to -15v for a logical “1,” and +5v to +15v for a logical “0,” the outputs from the Raspberry Pi would also need a level shifter circuitry (like the MAX3232CPE chip [ED. NOTE: I have revised this to include info supplied in comments below]) to generate the appropriate voltages.

If you wish to generate RS-422 or RS-485 signalling, then a line driver like the SP3485 is required.

GPIO pin assignments

The serial I/O on the Raspberry Pi pin header is as follows:

Raspberry Pi GPIO serial pin assignments

Raspberry Pi GPIO serial pin assignments

 Sources:

CM2835 ARM Peripherals specification sheet (Broadcom BCM 2835 specification sheet: the core of the Raspberry Pi)
PrimeCell® UART (PL011) Revision: r1p4 Technical Reference Manual (PrimeCell UART (PL011): the UART in the Broadcom BCM 2935)
http://www.raspberrypi.org/forum/general-discussion/gpio-pinouts-confirmed/page-3 Raspberry Pi forum discussion on serial implementation for the Raspberry Pi)

Raspberry Pi production build schematics (NOTE: GPIO pin assignments have varied in the pre-release history of the Raspberry PI. Please confirm current pinouts before implementing serial I/O on the Raspberry Pi.)

A USB-to-TTL solution to level shifting on the Raspberry Pi

An interesting description of software (Debian Linux) access to use the mini-UART serial port in non-console mode

A beginner’s level discussion of serial interfacing on the Raspberry Pi

Farnell has a Quickstart Guide that discusses serial connection to the Raspberry Pi (NOTE: Take care when connecting that you are not sending a higher voltage into the Raspberry Pi than it can handle; this Quickstart Guide is not explicit on this point)