5: BASIC Stamp Command Reference – I2CIN
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 141
Every I
2
C transmission session begins with a Start Condition and ends
with a Stop Condition. Additionally, immediately after every byte is
transmitted, an extra clock cycle is used to send or receive an
acknowledgment signal (ACK). All of these operations are automatically
taken care of by the I2CIN command so that you need not be concerned
with them. The general I
2
C transmission format is shown in Figure 5.8.
Since the I2CIN command is intended for input only, it actually overrides
the "R/W" bit (bit 0) in the SlaveID argument. This is done so that it can
use the I
2
C protocol's "Combined Format" for receiving data. Put simply,
this means a command such as: I2CIN 0, $A1, 10, [Result] actually
transmits $A0, then 10, then $A1 and then it reads the data back from the
device. The $A0 means "write", the 10 is the address to write to and,
finally, the $A1 indicates a change of direction; to "read" the location,
instead. Even though the I2CIN command really doesn't care what the
value of the SlaveID's LSB is, it is suggested that you still set it
appropriately for clarity.
Also note that the I2CIN command does not support multiple I
2
C masters
and the BASIC Stamp cannot operate as an I
2
C slave device.
Demo Program (I2C.bsp)
' This program demonstrates writing and reading every location in the 24LC16B EEPROM
' using the BS2p's I2C commands. Connect the BS2p to the 24LC16B DIP EEPROM as
' shown in the diagram in the I2CIN or I2COUT command description.
'{$STAMP BS2p} 'STAMP directive (specifies a BS2p)
S
PECIAL NOTE ABOUT
I2CIN
INPLIMENTATION
.
Figure 5.8: I
2
C Transmission
Format.
S
P
S
T
A
R
T
SlaveID
A
C
K
Address
A
C
K
Data
A
C
K
S
T
O
P
B
U
S
F
R
E
E
a
6
a
5
a
4
a
3
a
2
a
1
a
0
rw
a
6
a
5
a
4
a
3
a
2
a
1
a
0
a
7
d
6
d
5
d
4
d
3
d
2
d
1
d
0
d
7
NOTES:
S = Start Condition
P = Stop Condition
a = id or address bit
d = data bit (transmitted by the BASIC Stamp or the I C device)
ACK = Acknowledge signal. (Most acknowledge signals are generated by the I C device)
2
2
p
2
S
TART AND
S
TOP
C
ONDITIONS AND
A
CKNOWLEDGMENTS
.
Содержание BASIC Stamp 1
Страница 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...