TotalPhase-Blog-Erlebniswelten

SPI/I2C slave AA_COMMUNICATION_ERROR using an aardvark

You activated an I2C/SPI slave, already received messages from it and now want to deactivate it, but you get a status code AA_COMMUNICATION_ERROR.? This is probably not a bug in your code!

 

Explanation:

It can happen that a master sends large amounts of data and thereby completely occupies the host PC receive buffer for the Aardvark I2C / SPI host adapter. The communication error means that while the PC was sending the deactivation request to the slave, no acknowledgment was received from the Aardvark adapter. 

 

In most cases the slave was probably disabled. When the Aardvark adapter has deactivated the slave, no further data is sent or received, so the connection/buffer can no longer be fully occupied. A subsequent call to disable the slave should return with no errors.

 

Possible solutions:

While this is not necessarily a critical issue in your code, there are a number of ways you can improve the situation. 


a.) One is to reduce the amount of traffic sent by the master. This requires the ability to reconfigure the offending master device. 

 

b.) Another option is to periodically poll the slave to get pending asynchronous messages. Note that each call to read pending messages can time out up to 500ms. So if there is other time-sensitive code that needs to run concurrently, it's best to use a threading model. (Aardvark adapter API calls are not thread safe, but can be used if wrapped in appropriate thread synchronization calls.)


For the most powerful development environments it is advisable to use two Aardvark adapters. One Aardvark adapter can be configured to receive the asynchronous I2C/SPI slave messages and the other can be used for synchronous I2C/SPI master communication. With this configuration, one thread in the application can tightly loop to process the slave messages and another thread can handle synchronous operations. 

I2C & SPI development tools

Aardvark I2C/SPI Host AdapterAardvark I2C/SPI Host Adapter
Aardvark I2C/SPI Host Adapter
TP240141
Erase, program, verify Memory Devices - The Aardvark I2C/SPI Host Adapter is a fast and powerful I2C bus and SPI bus host adapter through USB.

€309.00*
Beagle I2C/SPI Protokoll Analyzer - Total Phase
Beagle I2C/SPI Protocol Analyzer
TP320121
The versatile Beagle I2C/SPI Protocol Analyzer is the ideal tool for the embedded engineer who is developing an I2C, SPI, or MDIO based product.

€369.00*
Promira I2C/ SPI/ eSPI Platform
TP500110-S
Promira is a universal hardware platform usable for a variety of applications, like I2C, SPI and eSPI.

Variants from €900.00*
€1,060.00*