In Batch Mode, How Do I Control Stop Bits when Sending Data to an I2C Device?

Question from the Customer:

I am using the Control Center Serial Software with the Aardvark I2C/SPI Host Adapter. I need to send data to an I2C device with and without the stop bit – is there a way I can control the behavior of the stop bit? Here is the sequence of what I need to execute:

Master Write 0x63, 0x01 with the stop bit.
Master Write 0x63, 0x03 with no stop bit.
Master Read 0x63, and 18 bytes with the stop bit.

I’d also like to run the commands in batch mode.

Response from Technical Support:

Thank you for your questions! We have a solution for you – we’ll start with an overview running commands using the Control Center Serial Software, and then provide an example of commands for the batch script. We’ll use 0x63 as the address for the I2C target slave address.

Manually Entering Commands to Control Stop Bits

Here is a view of the Master dialog of the Control Center Serial Software.

Master dialog of the Control Center Serial Software

Master Write

  1. In the Slave Addr field, enter 0x63.
  2. Uncheck the No Stop.
  3. In the Master Write Message window, enter 01.
  4. Click the Master Write.

Master Read

There are two methods for the Read command that follows Master Write, which are described below.

Master Read - method 1

  1. In the Slave Addr field, enter 0x63.
  2. Check the No Stop.
  3. Enter 03 in the Master Write Message window.
  4. Under the Master Read Section:
    1. In the Number of Data Byes field, enter 18.
    2. Click the Master Write.
    3. Immediately click the Master Read.

Master Register Read – method 2

  1. In the Slave Addr field, enter 0x63.
  2. Under the Master Register Read section:
    1. In the Register Address field, enter 0x03.
    2. In the Address Width filed, select 1 byte.
    3. In the Number of Data Byes field, enter 18.
    4. Click the Master Register Read.

Controlling Stop Bits in Batch Mode

Here is an example what the code could look like in batch mode. For reading, this example uses method 1.

<adapter>

<configure i2c="1" spi="1" gpio="0" tpower="1" pullups="1"/> <i2c_bitrate khz="100"/><i2c_write addr="0x63" count="1" radix="16" nostop="0">01</i2c_write>
<i2c_write addr="0x63" count="1" radix="16" nostop="1">03</i2c_write>
<i2c_read addr="0x63" count="18"/>

</adapter>

To run batch code:

  1. Connect the Aardvark adapter to Control Center Serial Software
  2. Choose Adapter -> Batch Mode

There are two ways to run batch code: manually enter the code or execute a file. This information is provided in the following sections.

Manually Enter and Run the Batch Code

You can manually enter the commands and run the file in the Batch Mode dialog, as shown below.

Batch Mode Dialog of the Control Center Serial Software

Execute a Batch File

You can also save the commands in a file, and then run the file. You use the Batch Mode dialog, which is illustrated above.

  1. In the Batch Mode dialog, click the Load button and then choose the desired file.
  2. Click the Execute button.

Information about Batch Commands

Information about batch instruction commands is available in the Control Center Serial Software. To obtain the information, click the Help button and the following dialog will appear.

List of Batch Commands available in Control Center Serial Software

Additional resources that you may find helpful include the following:

We hope this answers your questions. If you have other questions about our Total Phase products, feel free to email us at sales@totalphase.com. You can also request a demo specific for your application.