Hardware Reference
In-Depth Information
The two I2C bus lines are provided on the header strip P1:
Rev 1.0
Rev 2.0 +
P1
GPIO
I2C
Bus
GPIO
I2C
Bus
P1-03
0
SDA0
I2C-0
2
SDA1
I2C-1
P1-05
1
SCL0
3
SCL1
Note that the original Raspberry Pi provided I2C bus 0, but switched to using bus 1
with Rev 2.0 and later units.
The design of the I2C bus is such that multiple peripherals are attached to the SDA
and the SCL lines. Each slave (peripheral) has its own unique 7-bit address. For example,
the MCP23017 GPIO extender peripheral might be configured with the address of 0x20.
Each peripheral is called upon by the master by using this address. All nonaddressed
peripherals are expected to remain quiet so that communication can proceed with the
selected slave device.
SDA and SCL
The two bus lines used for I2C are as follows:
Line
P1
Idle
Description
SDA
P1-03
High
Serial data line
SCL
P1-05
High
Serial clock line
Both masters and slaves take turns at “grabbing the bus” at various times. Master and
slave use open-drain transistors to drive the bus. It is because all participants are using
open-drain drivers that pull-up resistors must be used (provided by the Pi). Otherwise,
the data and clock lines would float between handoffs.
The open-drain driver design allows all participants to drive the bus lines—just not at
the same time. Slaves, for example, turn off their line drivers, allowing the master to drive
the signal lines. The slaves just listen, until the master calls them by address. When the
slave is required to answer, the slave will then assert its driver, thus grabbing the line. It is
assumed by the slave that the master has already released the bus at this point. When the
slave completes its own transmission, it releases the bus, allowing the master to resume.
The idle state for both lines is high. The high state for the Raspberry Pi is +3.3 V.
Other systems may use +5 V signaling. When shopping for I2C peripherals, you'll want to
choose ones that will operate at the 3 V level. Otherwise, 5 V peripherals can sometimes
be used with careful planning or with use of signal adapters. The DS1307 Real-Time clock
project is one such a case that is covered in Chapter 4 of Experimenting with Raspberry Pi
(Apress, 2014).
 
 
Search WWH ::




Custom Search