Parallax BASIC Stamp 2e Programming Manual page 149

Table of Contents

Advertisement

S
S
C
TART AND
TOP
ONDITIONS AND
A
.
CKNOWLEDGMENTS
2
Figure 5.11: I
C Transmission
Format.
S
I2COUT
PECIAL NOTE ABOUT
.
INPLIMENTATION
5: BASIC Stamp Command Reference – I2COUT
2
Every I
C transmission session begins with a Start Condition and ends
with a Stop Condition.
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
S
T
A
SlaveID
R
T
S
a
a
a
a
a
a
6
5
4
3
2
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)
Since the I2COUT command is intended for output only, it actually
overrides the "R/W" bit (bit 0) in the SlaveID argument. This is done to
avoid device conflicts should the value be mistyped. Put simply, this
means commands such as: I2COUT 0, $A0, 10, [0] and I2COUT 0, $A1,
10, [0] both transmit the same thing ($A0, then 10, then the data). Even
though the I2COUT 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 I2COUT command does not support multiple I
masters and the BASIC Stamp cannot operate as an I
2
Demo Program (I2C.bsp)
p
' 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}
Idx
VAR
WORD
Check
VAR
NIB
Result
VAR
BYTE(16)
WriteToEEPROM:
BASIC Stamp Programming Manual 2.0c • www.parallaxinc.com • Page 147
Additionally, immediately after every byte is
2
C transmission format is shown in Figure 5.11.
A
Address
C
K
a
rw
a
a
a
a
a
a
1
0
7
6
5
4
3
2
'STAMP directive (specifies a BS2p)
'Index variable for address
'Index for checking returned values
'16-byte array for returned value
A
Data
C
K
a
a
d
d
d
d
d
d
d
1
0
7
6
5
4
3
2
1
2
2
C slave device.
B
U
S
F
S
R
A
T
E
C
O
E
K
P
P
d
0
2
2
C

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?

Table of Contents