Hardware Reference
In-Depth Information
UARTs and Logic Shifters
You probably have caught on by now that I keep using the term “UART” when talking about the Raspberry Pi. There
is a good reason for this. From an electronics point of view it is just a UART and it's not going to be useful as a serial
port without other components. I want you to understand that a UART is just part of a serial port; it's not a serial port.
If you were to connect a serial device to the TX and RX pins on your Raspberry Pi you will be up for a brand-new
Raspberry Pi. After all, the Raspberry Pi has no logic-level shifter. So please do not connect a serial device to
your Raspberry Pi just yet. I am going to show you how to build a simple logic-level shifter now.
What Does a Logic-Level Shifter Do?
A logic-level shifter solves a very common problem in digital circuits. That problem is how to drive a higher voltage
logic circuit from a lower voltage logic circuit. In your case how can you drive a potential 25-V serial port signal from
a 3.3-V device? This is where the logic shifter comes in.
The logic-level shifter will take a given signal on the 3.3-V logic side also known as the transistor-transistor logic
side, or TTL for short, and convert it up to the correct voltage but still keep the same logic value. Logic-level shifters
use a concept called a charge pump to boost the voltage up from the lower input voltage to the higher voltage as
needed. A charge pump is a circuit that uses capacitors to store a small charge so that it can boost the voltage when
needed. This is why you always see a large number of capacitors near logic-level shifter circuits.
The most widely known logic-level shifter that is known when you are talking about serial ports is the Maxim
MAX232 and its clones.
Needed Hardware
The MAX232 has been around for many years and works fine if you have a 5-V supply for it. Because the Raspberry
Pi is a 3.3-V logic device I did not want to use the MAX232. You want a logic-level shifter that poses no risk to the
Raspberry Pi, one that could be driven from the Pi itself. After all, if you're creating a serial console you don't want to
rely on an external power source; otherwise you may miss the start of the boot process. For this task I have selected
the MAX3232. This can be powered via 3.3 V and has a very low current draw. It's also in a dual in-line package (DIP)
package so it's quite easy for you to work with. Functionality-wise, it is exactly the same as the MAX232. If you have
worked with the MAX232 you won't have any issues using the MAX3232.
The MAX3232 is able to convert two pairs of send and transmit signals; now this would have been ideal if we
had a second UART on the Raspberry Pi that could be accessed at the same time. You could use one MAX3232 to
logic-shift the two UARTs. The MAX3232 converts TTL signals into RS-232-compliant signaling. With the use of
the charge pumps, it can supply from -5.5 V to +5.5 V. This will give you a fully RS-232-complaint serial port. The
MAX3232 is guaranteed to run at a speed up to 120 kb/s, which makes it easy to support the Raspberry Pi's default
UART speed of 14.4 kb/s.
Now that you know what IC you're going to use I will now give you the full list of components for this chapter.
You're going to need the following to build the circuit:
One MAX3232
Five 0.1-
mf capacitors
One DB9 shell
Hook-up wire
I like to keep things simple where at all possible. As always, take a look at the electronic schematic in Figure 9-3 .
 
Search WWH ::




Custom Search