27220 Parallax Inc, 27220 Datasheet - Page 194

BOOK STAMPWORKS

27220

Manufacturer Part Number
27220
Description
BOOK STAMPWORKS
Manufacturer
Parallax Inc
Datasheet

Specifications of 27220

Accessory Type
Booklet
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
StampWorks
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Not applicable / Not applicable
The I2C specification actually allows for multiple Masters to exist on a common bus
and provides a method for arbitrating between them. That's a bit beyond the scope
of what we need to do so we're going to keep things simple. In our setup, the BS2
(or BS2e or BS2sx) will be the Master and anything connected to it will be a Slave.
You'll notice in I2C schematics that the SDA (serial data) and SCL (serial clock) lines
are pulled up to Vdd (usually through 4.7 kΩ). The specification calls for device bus
pins to be open drain. To put a high on either line, the associated bus pin is made
an input (floats) and the pull-up takes the line to Vdd. To make a line low, the bus
pin pulls it to Vss (ground).
This scheme is designed to protect devices on the bus from a short to ground. Since
neither line is driven high, there is no danger. We're going to cheat a bit. Instead of
writing code to pull a line low or release it (certainly possible – I did it), we're going
to use SHIFTOUT and SHIFTIN to move data back and forth. Using SHIFTOUT and
SHIFTIN is faster and saves precious code space. If you're concerned about a bus
short damaging the BASIC Stamp's SDA or SCL pins during SHIFTOUT and
SHIFTIN, you can protect each of them with a 220 ohm resistor. If you’re careful
with your wiring and code this won’t be necessary.
Low Level I2C Code
At its lowest level, the I2C Master needs to do four things:
A Start condition is defined as a high-to-low transition on the SDA line while the SCL
line is high. All transmissions begin with a Start condition. A Stop condition is
defined as a low-to-high transition of the SDA line while the clock line is high. A Stop
condition terminates a transfer and can be used to abort it as well.
Generate a Start condition
Transmit 8-bit data to the Slave
Receive 8-bit data from Slave – with or without Acknowledge
Generate Stop condition

Related parts for 27220