I2CIN - BASIC Stamp Command Reference
Page 138
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
Explanation
The I
2
C protocol is a form of synchronous serial communication developed
by Phillips Semiconductors. It only requires two I/O pins and both pins
can be shared between multiple I
2
C devices. The I2CIN command allows
the BASIC Stamp to receive data from an I
2
C device.
The following is an example of the I2CIN command:
Result VAR BYTE
I2CIN 0, $A1, 0, [Result]
This code will transmit a "read" command to an I
2
C device (connected to
I/O pins 0 and 1) and then will receive one byte and store it in the variable
Result. Though it may seem strange, the I2CIN command first transmits
some data and then receives data. It must first transmit information (ID,
read/write and address) in order to tell the I
2
C device what information it
would like to receive. The exact information transmitted ($A1, 0) depends
on the I
2
C device that is being used.
The above example will read a byte of data from location 0 of a 24LC16B
EEPROM from Microchip. Figure 5.6 shows the proper wiring for this
example to work. The SlaveID argument ($A1) is both the ID of the chip
and the command to read from the chip; the 1 means read. The Address
argument (0) is the EEPROM location to read from.
The I2CIN command's InputData argument is similar to the SERIN
command's InputData argument. This means data can be received as
ASCII character values, decimal, hexadecimal and binary translations and
string data as in the examples below. (Assume the 24LC16B EEPROM is
used and it has the string, "Value: 3A:101" stored, starting at location 0).
A
SIMPLE
I2CIN
EXAMPLE
.
R
ECEIVING FORMATTED DATA
.
Figure 5.6: Example Circuit for the
I2CIN command and a 24LC16B
EEPROM. Note: The 4.7 K
Ω
Ω
resisters are required for the
I2CIN command to function
properly.
Vss
P1
Vdd
4.7 k
Ω
P0
24LC16B
(DIP)
4.7 k
Ω
SDA
SCL
1
2
3
4
8
7
6
5
Содержание BASIC Stamp 2e
Страница 1: ...BASIC Stamp Programming Manual Version 2 0c...
Страница 30: ...Introduction to the BASIC Stamps Page 28 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 90: ...BUTTON BASIC Stamp Command Reference Page 88 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 118: ...END BASIC Stamp Command Reference Page 116 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 128: ...FREQOUT BASIC Stamp Command Reference Page 126 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 196: ...NAP BASIC Stamp Command Reference Page 194 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 206: ...OWIN BASIC Stamp Command Reference Page 204 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 214: ...OWOUT BASIC Stamp Command Reference Page 212 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 216: ...PAUSE BASIC Stamp Command Reference Page 214 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 226: ...POLLMODE BASIC Stamp Command Reference Page 224 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 232: ...POLLOUT BASIC Stamp Command Reference Page 230 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 236: ...POLLRUN BASIC Stamp Command Reference Page 234 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 240: ...POLLWAIT BASIC Stamp Command Reference Page 238 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 262: ...RCTIME BASIC Stamp Command Reference Page 260 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 274: ...RUN BASIC Stamp Command Reference Page 272 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 310: ...SEROUT BASIC Stamp Command Reference Page 308 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 324: ...STOP BASIC Stamp Command Reference Page 322 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...