I2C SPI USB CAN eSPI Cable Testing View All Quick Start Guides User Manuals Software Downloads Knowledge Base Videos Case Studies App Notes White Papers Sales Support About Us
Products Blog Sales Support Contact Search
Control Center Serial Software Series: XML Batch Scripting for Automated Tasks
Jessica Hopkins

The Total Phase Control Center Serial Software allows engineers working with the Aardvark I2C/SPI Host Adapter, Cheetah SPI Host Adapter, and Promira Serial Platform to develop and test their embedded systems.

When using these host adapters with the Control Center Serial Software, users can perform a variety of tasks; particularly, the Batch Mode feature allows for XML batch scripting to automate tasks.

In this blog, we’ll discuss the Batch Mode functionality, how to use it, and some use cases that can applied using this feature.

What is XML Batch Scripting and Batch Mode?

A batch script is a file that contains a series of commands that are executed in sequence.  This is helpful in automating tasks that are generally repetitive.

In the Control Center Serial Software, the Batch Mode feature allows users specify an arbitrary set of instructions for the adapter to execute serially. This scripting language is based on XML.

Use Cases for Batch Mode

Reading and Writing to a Target Device

The Control Center Serial Software allows users to read and write to I2C or SPI target devices, but also allows users to automate such tasks using the Batch Mode feature. For instance, if users are looking to efficiently write a series of commands or perform multiple reads at once, this can be easily achieved.

Below is an example of batch instruction commands that read and write 2 bytes at 100 kHz to and from the I2C slave address 0x50:

<aardvark>

<configure i2c="1" spi="1" gpio="0" tpower="1" pullups="1"/>

<i2c_bitrate khz="100"/>

<i2c_write addr="0x50" count="2" radix="16">00 11</i2c_write>

<i2c_read addr="0x50" count="2"/>

</aardvark>

Below are the parameters for this example:

Configuration:

  • I2C mode: i2c="1" spi="1" gpio="0"
  • Enable target power: tpower="1"
  • Enable I2C pullups: pullups="1"

Bitrate:

  • Requested bitrate in kHz: khz="100”

Write:

  • Device address: addr="0x50"
  • Number of data bytes: count="2"
  • Data format: radix="16" (hexadecimal)

Read:

  • Device address: addr="0x50"
  • Number of data bytes: count="2"

Reading Registers on an I2C Device

Users may also want to perform read and write commands to the registers of the target device to transfer I2C data to multiple sub-addresses. Using the Master Register Read function in I2C/SPI Mode in Control Center Serial Software allows users to perform this, but there is no direct command for this in Batch Mode. To perform this function, users can implement a register read in Batch Mode by using a “nostop” command following this configuration:

  • First operation: I2C write with no stop
  • Second operation: I2C read with stop

The example below reads 4 bytes at 100 kHz from I2C slave address 0x50 at register address 08:

<aardvark>

<configure i2c="1" spi="1" gpio="0" tpower="1" pullups="1"/>

<i2c_bitrate khz="100"/>

<i2c_write addr="0x50" count="1" radix="16" nostop="1">08</i2c_write>

<i2c_read addr="0x50" count="4"/>

</aardvark>

Where nostop="1" enables this parameter in the batch instruction commands and nostop="0" disables it.

Click here for more information on how to set up and perform a "Master Register Read" in Batch Mode.

Verifying a System Setup

Users can also use Batch Mode to more efficiently verify that a system set up is working as expected. When using a Total Phase host adapter with the Control Center Software and a Total Phase I2C/SPI Activity Board, users can program a test SPI or I2C device by executing an XML batch script.

I2C/SPI Activity Board

This will allow users to execute a more detailed testing procedure and easily confirm their batch instruction commands are operating correctly before committing to a widespread operation.

For instructions on how to verify a test set up, please click here.

How to Use Batch Mode within the Control Center Serial Software

Using the Batch Mode feature is a quick and simple process.

Batch Mode Console

To manually enter the commands and run the file in the Batch Mode console:

  1. Launch the Control Center Serial Software.
  2. Click on Adapter | Connect and connect to the Aardvark adapter
  3. Connect the Aardvark adapter to the Activity board.
  4. Click on Adapter | Batch Mode
  5. Manually enter commands in the Batch Mode console
  6. Click Execute.
  7. Monitor transactions in the transaction log window.

 

To load an existing XML file and run in the Batch Mode console:

  1. Launch the Control Center Serial Software.
  2. Click on Adapter | Connect and connect to the Aardvark adapter
  3. Connect the Aardvark adapter to the Activity board.
  4. Click on Adapter | Batch Mode
  5. Click on Load and select the XML file
  6. Click Execute.
  7. Monitor transactions in the transaction log window.

To see a video demonstration on how to use Batch Mode, please watch Programming an EEPROM with a Total Phase I2C Host Adapter.

Help Commands for Generating XML Batch Scripts

To use Batch Mode, a set of batch instruction commands needs to be generated in XML script format. For maximum flexibility, Batch Mode supports I2C, SPI, and GPIO functions.

For users looking for extra assistance with setting up batch instruction commands, the Control Center Serial Software includes Help Instructions that provide written instructions and guidance on how to configure the commands.

Help Commands for XML Batch Scripting

For complete instructions on how to set up an XML batch script, please see the user manual section 4.5 on Batch Mode.

Using an API to Create Custom Programs

While Batch Mode is a useful feature for a variety of use cases, developers may want to program custom solutions based on their own project requirements. Total Phase offers a free API for each of our tools including the Aardvark I2C/SPI Host Adapter, Cheetah SPI Host Adapter, and Promira Serial Platform. These tools can be used with our Control Center Serial Software to easily send data to I2C and SPI devices, but the same concepts can be applied to API functions. For instance, by using the respective adapter API, users can perform complex actions including:

  • looping for repeatedly sending commands
  • integrating with a custom GUI to execute batch commands in a separate terminal

Our APIs offer cross-platform support including Windows, Linux, and Mac, and support multiple languages like C, C#, Python 2/3, .NET, VB.NET, and VB6. Examples are also included that show how the API works, which can be modified and applied to your specific applications.

Click here to find the Software API for our host adapter tools:

If you have any questions on how Batch Mode can help complete your own programming applications, please email us at sales@totalphase.com.