More on Raspberry Pi serial ports
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:
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.
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:
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.)
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)