Writing Scripts
The first byte following an
r
(read) or
w
(write) command is the I
2
C slave address of the device (if I
2
C is
used) or the first data byte to write. (If SPI is used, note that SPI interfaces are not standardized on
protocols, so the meaning of this byte varies with the device being addressed on the SPI bus.) The
second byte is the starting register address that data will be written to (again, with I
2
C; SPI varies).
Following these two bytes are data, if writing; if reading, the third byte value is the number of bytes to
read, (expressed in hexadecimal).
For example, to write the values 0xAA 0x55 to an I
2
C device with a slave address of 0x30, starting at a
register address of 0x03, the user writes:
#example script
I i2cfast
w 30 03 AA 55
r 30 03 02e
This script begins with a comment, specifies that a fast I
2
C bus is used, then writes
0xAA 0x55
to the I
2
C
slave device at address 0x30, writing the values into registers 0x03 and 0x04. The script then reads back
two bytes from the same device starting at register address 0x03. Note that the slave device value does
not change. It is unnecessary to set the R/W bit for I
2
C devices in the script; the read or write commands
does that.
If extensive repeated write commands are sent and commenting is desired for a group of bytes, the >
command can be used to extend the bytes to other lines that follow. A usage example for the > command
follows:
#example script for '>' command
I i2cfast
# Write AA and BB to registers 3 and 4, respectively
w 30 03 AA BB
# Write CC, DD, EE and FF to registers 5, 6, 7 and 8, respectively
> CC DD EE FF
# Place a commented breakpoint
b "AA BB CC DD EE FF was written, starting at register 3"
# Read back all six registers, starting at register 3
r 30 03 06b
The following example demonstrates usage of the Wait for Flag command,
f
:
#example script for 'wait for flag' command
I i2cfast
# Switch to Page 44
w 30 00 2C
# Switch buffer
w 30 01 05
# Wait for bit D0 to clear. 'x' denotes a don't care.
f 30 01 xxxxxxx0
Any text editor can be used to write these scripts; jEdit is an editor that is highly recommended for general
usage. For more information, go to:
.
23
SLAU564A – February 2014 – Revised February 2014
TLV320AIC3268EVM-U Evaluation Module
Copyright © 2014, Texas Instruments Incorporated