SLAU855A June 2021 – March 2022 TLV320AIC3101 , TLV320AIC3104 , TLV320AIC3104-Q1 , TLV320AIC3105 , TLV320AIC3106 , TLV320AIC3106-Q1 , TLV320AIC3107 , TLV320AIC3109-Q1 , TLV320AIC34
A script is simply a text file that contains data to send to the serial control buses. The scripting language is quite simple, as is the parser for the language. Therefore, the program is not very forgiving about mistakes made in the source script file, but the formatting of the file is simple. Consequently, mistakes tend to be rare.
Each line in a script file is one command. There is no provision for extending lines beyond one line. A line is terminated by a carriage return.
The first character of a line is the command. Commands are listed in Table 3-7.
Command | Description |
---|---|
i | Set interface bus to use |
r | Read from the serial control bus |
w | Write to the serial control bus |
# | Comment |
b | Break |
d | Delay |
The first command, i, sets the interface to use for the commands to follow. This command must be followed by one of the parameters listed in Table 3-8.
Command | Description |
---|---|
i2cstd | Standard mode I2C Bus |
i2cfast | Fast mode I2C bus |
spi8 | SPI bus with 8-bit register addressing |
spi16 | SPI bus with 16-bit register addressing |
gpio | Use the USB-MODEVM GPIO capability |
For example, if a fast mode I2C bus is used, the script begins with i i2cfast.
No data follows the break command. The text following a comment command is ignored by the parser, provided that the text is on the same line. The delay command allows the user to specify a time, in milliseconds, that the script pauses before proceeding.
Unlike all other numbers used in the script commands, the delay time is entered in a decimal format. Also, because of latency in the USB bus as well as the time required for the processor on the USB-MODEVM to handle requests, the delay time may not be precise.
A series of byte values follows either a read or write command. Each byte value is expressed in hexadecimal, and each byte must be separated by a space. Commands are interpreted and sent to the TAS1020 by the program using the protocol described in Section 3.4.
The first byte following a read or write command is the I2C slave address of the device (if I2C is used) or the first data byte to write (if SPI is used, 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 are written to (with I2C the SPI varies, see Section 3.4 for additional information about what variations may be necessary for a particular SPI mode). If reading, data follow these two bytes. 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 I2C device with a slave address of 0x90, starting at a register address of 0x03, write:
#example script
i i2cfast
w 90 03 AA 55
r 90 03 2
This script begins with a comment, specifying that a fast I2C bus will be used, then writes 0xAA 0x55 to the I2C slave device at address 0x90, and writes the values into registers 0x03 and 0x04. The script then reads back two bytes from the same device starting at register address 0x03. The slave device value does not change. The R/ W bit does not need to be set for I2C devices in the script; the read or write commands will do that.
Here is an example of using an SPI device that requires 16-bit register addresses:
# setup TSC2101 for input and
output
# uses SPI16 interface
# this script sets up DAC and
ADC at full volume, input from onboard mic
#
# Page 2: Audio control
registers
w 10 00 00 00 80 00 00 00 45
31 44 FD 40 00 31 C4
w 13 60 11 20 00 00 00 80 7F
00 C5 FE 31 40 7C 00 02 00 C4 00 00 00 23 10 FE 00 FE 00
Blank lines are allowed. However, be sure that the script does not end with a blank line. Although ending with a blank line does not cause the script to fail, the program executes that line, and therefore, may prevent the user from seeing data written or read back on the previous command.
In this example, the first two bytes of each command are the command word to send to the TSC2101 (0x1000, 0x1360); these are followed by data to write to the device starting at the address specified in the command word. The second line may wrap in the viewer being used to look like more than one line; careful examination will show, however, that there is only one carriage return on that line, following the last 00.
Any text editor may be used to write these scripts; Jedit is an editor that is highly recommended for general usage. For more information, go to: http://www.jedit.org.
Once the script is written, this script can be used in the command window by running the program, and then selecting Open Command File... from the File menu. Locate and open the script. The script is then displayed in the command buffer. The user may also edit the script when in the buffer, but saving of the command buffer is not possible at this time (this feature may be added at a later date).
Once the script is in the command buffer, the script may be executed by pressing the Execute Command Buffer button. If there are breakpoints in the script, the script executes to that point, and the user is presented with a dialog box with a button to press to continue executing the script. When ready to proceed, push that button and the script continues.
Here an example of a (partial) script with breakpoints:
# setup AIC33 for input and
output
# uses I2C interface
i i2cfast
# reg 07 - codec datapath
w 30 07 8A
r 30 07 1
d 1000
# regs 15/16 - ADC volume,
unmute and set to 0dB
w 30 0F 00 00
r 30 0F 2
b
This script writes the value 8A at register 7, then reads the register back to verify that the write was good. A delay of 1000 ms (one second) is placed after the read to pause the script operation. When the script continues, the values 00 00 are written starting at register 0F. This output is verified by reading two bytes, and pausing the script again, this time with a break. The script does not continue until the user presses OK in the dialog box that will be displayed because of the break.