Hardware Reference
In-Depth Information
I 2 C devices tend to be small with few pins. (Most devices have the bare mini-
mum.) Therefore, it is rarely possible to coni gure your own addresses for these
devices. Most devices therefore have addresses that are specii ed by the manu-
facturer. On an ordinary computer network, it is easy to have dozens of the same
type of computer with a user settable IP address unique to each machine. On an
I 2 C network, this isn't possible; two identical sensors will use the same address.
To allow developers to have several sensors in the same network, some devices
allow you to change the address depending on input pins. By connecting one
or several pins to either +5 V or 0 V, you can set part of the address (usually
the lower bits). You might therefore have several temperature sensors, using
addresses 0x90, 0x91, and 0x92, as shown in Figure 8-5.
+5 V
+5 V
A0
A0
A0
SDA
A1
A2
A1
A2
A1
A2
LM75A
LM75A
LM75A
SCL
0×90
0×91
0×92
Figure 8-5: Configuring different addresses
Communication
I 2 C works on the master/slave scheme; a master either requests information from
a slave or gives information to a slave. The master is responsible for initiating
contact before releasing the bus so that a slave may communicate. Slaves can-
not “talk” without permission; a slave cannot warn the system of an action; the
master must poll for this information. This is the big difference between I 2 C
and standard serial communication; it is not full duplex, meaning that devices
cannot send data and receive data at the same time. Only one master is on an
I 2 C network (except for some specii c coni gurations).
To talk to devices, I 2 C uses a system of registers. A register is a small memory
location on each device that can store data; it can be read or written to (some-
times both) depending on the type of data that is contained. For example, a
temperature sensor has a register that contains the current temperature. When a
master asks for information, it does not ask directly for the temperature; instead,
it asks for the contents of a register. A temperature sensor will, of course, have
a temperature register but might contain a coni guration register (Celsius or
Fahrenheit), a warning register (when this temperature is reached, an external
 
Search WWH ::




Custom Search