How Causes an Error Message When the Data Appears to Be Delivered Correctly?

Question from the Customer:

I am using the Aardvark I2C/SPI Host Adapter and Aardvark Software API to communicate with an I2C device. I have a question about an error message that conflicts with the results I see.

When I write 2 bytes and 5 bytes, the function aa_i2c_write returned 2 and 5 as expected. However, when I write 129 bytes, the return value is -103. Even though the function returned the error -103, I checked the device and found that all 129 bytes were successfully written to the device.

I am writing a sequence of bytes to the devices in the following order:  2 bytes, 129 bytes, 2 bytes, 129 bytes. I observed that most of the bytes were written successfully, yet some of the 2-byte sequences were missing. In another operation, the Aardvark host adapter wrote a chain of 512 bytes repeatedly for more than 100 times. In that case, the content written was correct.

What causes the error message? Is there a problem I’m not aware of?

Response from Technical Support:         

Thank you for your question! Based on your information, there may be a hardware issue that affects delivering the data. We’ll start with an overview of the read/write operations with the Aardvark host adapter, then describe the potential problem.

Communicating Data

This is an overview of the read and write operations.

Host Adapter Buffer

The sizes of the Aardvark host adapter’s I2C and SPI buffers are both 64 bytes. These buffers are only used when an Aardvark API call is invoked. The Aardvark has a 64-byte buffer for the slave response.

Therefore, the num_bytes parameter in the Aardvark API aa_i2c_read and aa_i2c_write is aa_u08 (8 bits). This 64 byte buffer size feature is “fixed”; it cannot be modified. However, if more bytes are requested in a transaction, the response string will be wrapped as many times as necessary to complete the transaction.

Write Operation

  • If the write operation is not completed properly by the API, the acknowledgement is not received from the slave, and returns the status AA_I2C_WRITE_ERROR (-103). Most likely, this is due to a communication error.
  • If the operation is complete with bytes written, the number of bytes written (a positive value) is returned.

USB Communication Errors

When the errors aa_i2c_read_error or aa_i2c_write__error are reported, that typically indicates the USB communication between the Aardvark host adapter and the computer is corrupted. This may occur when sending a large amount of data through the Aardvark host adapter, but the computer does not have the resources to grab all the data off of the device. One of the likely resources is the USB hub or the USB hub controller: managing a heavy use of full-speed USB traffic on the bulk endpoints.

A USB 2.0 hub may improve the situation. This way, using a high-speed communication between the host and hub pushes the processing of the full-speed traffic to the hub. What you can do:

  • Use a high-speed hub between the computer and the Aardvark adapter
  • Use a different computer, one that has a host controller on the motherboard

If you have a Beagle USB 480 Protocol Analyzer, you can also monitor and analyze the USB traffic between the computer and the Aardvark host adapter. This video demonstrates an example of using the Beagle USB 480 analyzer for debugging traffic, as well as the Aardvark host adapter.

We hope this answers your questions. Additional resources that you may find helpful include the following:

If you have other questions about our host adapters or other Total Phase products, feel free to email us at You can also request a demo that is specific for your application.

Request a Demo