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
Performing Random Reads with an I2C Slave
Performing random reads with an I2C slave

Contents

Introduction

This main purpose of this article is to show how to find relevant information from your device's datasheet, so that you can achieve your goals using Control Center.

The method for performing a random read differs among devices, and the method discussed in this article may need to be modified to work with your I2C device.

For this article, we use the Atmel AT24C02 I2C EEPROM, which is featured on our I2C/SPI activity board.

Exploring the Datasheet

The communication interface for each chip should be clearly defined in the manufacturer's datasheet. To determine how to perform a random read for the AT24C02, let's look though the datasheet and find the section that discusses the details:

Random Read section from AT24C02 datasheet

Random Read diagram from AT24C02 datasheet

The information above contains three important points:

  1. The word address of interest needs to be written first.
  2. A stop bit should not be sent after writing the word address.
  3. The slave will return the desired data after sendin a read instruction.

Performing Random Read

Let's read the byte stored at memory location 0x60. Note that the 7-bit address of our slave is 0x50.

In Control Center

  1. Enable target power and I2C pull-up resistors.
  2. Enter the 7-bit slave address in the "Slave Addr" text box. Remember, the Aardvark automatically appends the R/!W bit when sending an instruction.
  3. Check the "No Stop" box (the datasheet said there should not be a stop bit after dummy write).
  4. Write the memory address of interest to the slave (0x60 in this case).
  5. Read 1 byte from the desired memory location.

Control Center GUI after Random Read

The Control Center transaction log above shows that the byte 0xAA was stored at address 0x60.

Note: that the AT24C02 automatically increments the word address after each read, so pressing "Master Read" again will read the byte from address 0x61, then 0x62, and so forth. As displayed in the screenshot, 0xAB was stored at address 0x61.

In Batch Mode

The steps to perform a random read are the same, no matter which method you choose. To do this in Control Center's batch mode, you would use the following XML file:

<aardvark>   <configure i2c="1" spi="0" gpio="0" tpower="1" pullups="1"/>   <i2c_bitrate khz="100"/>   <i2c_write addr="0x50" count="1" radix="16" nostop="1">60</i2c_write>   <i2c_read addr="0x50" count="1"/> </aardvark>