I2CIN - BASIC Stamp Command Reference
Special Formatter
STR ByteArray \L {\E}
WAITSTR ByteArray {\L}
SKIP Length
2
The I
C protocol has a well-defined standard for the information passed at
the start of each transmission. First of all, any information sent must be
transmitted in units of 1 byte (8-bits). The first byte, we call the SlaveID, is
an 8-bit pattern whose upper 7-bits contain the unique ID of the device
you wish to communicate with. The lowest bit indicates whether this is a
write operation (0) or a read operation (1). Figure 5.7 shows this format.
The second byte, immediately following the SlaveID, is the Address. It
indicates the 8-bit address (within the device) containing the data you
would like to receive.
Some devices require more than 8 bits of address. For this case, the
optional LowAddress argument can be used for the low-byte of the required
address. When using the LowAddress argument, the Address argument is
effectively the high-byte of the address value. For example, if the entire
address value is 2050, use 8 for the Address argument and 2 for the
LowAddress argument (8 * 256 + 2 = 2050).
Following the last address byte is the first byte of data. This data byte may
be transmitted or received by the BASIC Stamp. In the case of the I2CIN
command, this data byte is transmitted by the device and received by the
BASIC Stamp. Additionally, multiple data bytes can follow the address,
depending on the I
limitations regarding how may contiguous bytes they can receive or
transmit in one session. Be aware of these device limitations and program
accordingly.
Page 140 • BASIC Stamp Programming Manual 2.0b • www.parallaxinc.com
Input a character string of length L into an array. If specified, an
end character E causes the string input to end before reaching
length L. Remaining bytes are filled with 0s (zeros).
Wait for a sequence of bytes matching a string stored in an array
variable, optionally limited to L characters. If the optional L
argument is left off, the end of the array-string must be marked
by a byte containing a zero (0).
Ignore Length bytes of characters.
7
6
5
4
3
2
A
A
A
A
A
A
6
5
4
3
2
2
C device. Note that every device has different
Action
1
0
A
R/W
1
0
Table 5.18: I2CIN Special
Formatters.
2
T
I
C
HE
PROTOCOL FORMAT
Figure 5.7: SlaveID Format.
U
L
.
SING
ONG ADDRESSES
.
Need help?
Do you have a question about the BASIC Stamp 2e and is the answer not in the manual?