I have an arm-based embedded controller that I use for thermal control when testing microprocessors. The controller communicates with multiple slave I2C temperature sensors including an I2C temperature sensor interface on our DUT (device under test). I would like to simulate this DUT interface with an Aardvark I2C/SPI Host Adapter in slave mode. I’ll be running a loop. I need the slave emulator to provide a different response - different sensor readings - for each loop cycle. How do I make this work?
Response from Technical Support:Thanks for your question! The I2C master can easily access (write/read) the Aardvark I2C/SPI Host Adapter in slave mode.
The transactions are listed below.
For write:
<START> I2C_SLAVE_ADDRESS_WRITE_COMMAND <ACK> <REGISTER_OFFSET> <ACK> <REGISTER_DATA> <ACK> <STOP>
For read:
<START>I2C_SLAVE_ADDRESS_WRITE_COMMAND<ACK><REGISTER_OFFSET<<ACK> <REPEATED_START> <I2C_SLAVE_ADDRESS_READ_COMMAND> <ACK> <DATA_FROM AARDVARK> <MASTER_NAK> <STOP>
The Aardvark adapter can deliver a single fixed response (up to 64 bytes) in response to the read command from the I2C master device. With a few extra commands using the Aardvark API software, you can have the Aardvark adapter provide a different response for each loop. You will need to run the loop in sync with a handshake; the I2C master device must wait for the Aardvark adapter to receive new data and then respond before sending the next read command. The API function to use is aa_i2c_slave_set_response. For details about API software, please refer to the API Documentation. Following is summary of running the loop to provide a different reading for each cycle:
Repeat steps 3-6 for each subsequent loop cycle. This handshake method is necessary for your setup; otherwise, each read will return the same data pattern, whether or not new data is set in the Aardvark adapter.
Additional resources that you may find helpful include the following:
We hope this answers your question. If you have other questions about our host adapters or other Total Phase products, feel free to email us at sales@totalphase.com, or if you already own one of our devices and have a technical question, please submit a request for technical support.