Hardware Reference
In-Depth Information
I 2 C Bus
As the name suggests, the Inter-Integrated Circuit (I²C) bus is designed to provide communica-
tions between multiple integrated circuits (ICs) . In the case of the Pi, one of those integrated
circuits is the Broadcom BCM2835 SoC processor at the heart of the system. These pins
include access to pull-up resistors located on the Pi, meaning no external resistors are required
to access the I 2 C functionality.
he I 2 C bus can be accessed on Pins 3 and 5, with Pin 3 providing the Serial Data Line (SDA)
signal and Pin 5 providing the Serial Clock (SCL) signal. The I 2 C bus available on these pins is
actually only one of two provided by the BCM2835 chip itself, and is known as I 2 C0. he
second, I 2 C1, is terminated at resistors on the Raspberry Pi circuit board itself and is not
available for general-purpose use.
SPI Bus
he Serial Peripheral Interface (SPI) bus is a synchronous serial bus designed primarily for in-
system programming (ISP) of microcontrollers and other devices. Unlike the UART and I²C
buses, it's a four-wire bus with multiple Chip Select lines, which allow it to communicate with
more than one target device.
The Pi's SPI bus is available on Pins 19, 21 and 23, with a pair of Chip Select lines on Pin 24
and Pin 26. Pin 19 provides the SPI Master Output, Slave Input (MOSI) signal; Pin 21 provides
the SPI Master Input, Slave Output (MISO) signal; Pin 23 provides the Serial Clock (SLCK) used
to synchronise communication; and Pins 24 and 26 provide the Chip Select signals for up to
two independent slave devices.
Although additional buses are present in the Raspberry Pi's BCM2835 SoC processor, they
are not brought out to the GPIO port and are thus unavailable for use.
Using the GPIO Port in Python
With the theory out of the way, it's time to get practical. In this section, you'll l learn how to
construct and program two simple electronic circuits that demonstrate how to use the GPIO
port for input and output.
As you saw in Chapter 12, “An Introduction to Python”, Python is a friendly yet powerful
programming language. It's not, however, the perfect choice for every scenario. Although it
works fine for the simple circuits you'll be creating in this chapter, it does not offer what is
known as deterministic real-time operation. For the majority of users, this doesn't matter; if
you're planning on using the Pi at the heart of a nuclear reactor or a complex robotics plat-
form, however, you may want to investigate a lower-level language such as C++ or even
assembler running on a dedicated real-time microcontroller .
Search WWH ::




Custom Search