BASIC stamp manual v2.2

I2COUT – BASIC Stamp Command Reference
Page 228 BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com
Special Formatter Action
?
Displays "symbol = x' + carriage return; where x is a number.
Default format is decimal, but may be combined with
conversion formatters (ex: BIN ? x to display
"x = binary_number").
ASC ?
Displays "symbol = 'x'" + carriage return; where x is an ASCII
character.
STR ByteArray {\L}
Send character string from an array. The optional \L argument
can be used to limit the output to L characters, otherwise,
characters will be sent up to the first byte equal to 0 or the end
of RAM space is reached.
REP Byte \L
Send a string consisting of Byte repeated L times
(ex: REP "X"\10 sends "XXXXXXXXXX").
Table 5.37: I2COUT Special
Formatters
The I
2
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.12 shows this format.
7
A
6
6
A
5
5
A
4
4
A
3
3
A
2
2
A
1
1
A
0
0
R/W
Figure 5.12: Slave ID Format
The second byte, immediately following the SlaveID, is the optional
Address. It indicates the 8-bit address (within the device) containing the
data you would like to receive. Note that the Address argument is optional
and may be left unspecified for devices that don't require an Address
argument.
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 I2COUT
command, this data byte is transmitted by the BASIC Stamp and received
by the device. Additionally, multiple data bytes can follow the address,
THE I
2
C PROTOCOL FORMAT.
U
SING LONG ADDRESSES.