Datasheet
www.ti.com
Writing Scripts
For example, writing the values 0xAA 0x55 to an I
2
C device with a slave address of 0x30, starting at a
register address of 0x03, the input is:
#example script
I i2cfast
w 30 03 AA 55
r 30 03 02
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. Setting the R/W bit for I
2
C devices in the script is unnecessary; the read or write command
does that.
If extensive repeated write commands are sent and commenting is desired for a group of bytes, the >
command extends the bytes to the following lines. 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 06
The following example demonstrates usage of the Wait for Flag command, f:
I i2cfast
# Switch to Page 44
w 30 00 2C
# Switch buffers
w 30 01 05
# Wait for bit D0 to clear. 'x' denotes a don't care.
f 30 01 xxxxxxx0
Write the scripts with a text editor; Jedit is a highly recommended, general-use editor. For more
information, go to: http://www.jedit.org.
Once the script is written, use it in the command window by running the program and then selecting Open
Script File... from the File menu. Locate the script and open it. The script is then displayed in the
command buffer. Edit the script once it is in the buffer and save it by selecting Save Script File... from the
File menu.
Once the script is in the command buffer, execute it by pressing the Execute Command Buffer button. If
there are breakpoints in the script, the script executes to that point and a dialog box with a continuation
button is presented, asking to continue execution of the script. When ready to proceed, push that button
and the script continues.
35
SLAU441–April 2012 Writing Scripts
Submit Documentation Feedback
Copyright © 2012, Texas Instruments Incorporated