Performing random reads with an I2C slave
Introduction
This article mainly shows how to find relevant information from the data sheet of your device so that you can achieve your goals with the help of the Control Center.
The method of performing a random read differs between devices, and the method described in this article may need to be modified to work with your I2C device.
For this article we are using the Atmel AT24C02 I2C EEPROM that is included on our I2C / SPI activity card.
Search the data sheet
The communication interface for each chip should be clearly defined in the manufacturer's data sheet. To determine how to do a random read for the AT24C02, let's look at the datasheet and find the section that explains the details:
Random Read section from the AT24C02 data sheet
Randomly reading the diagram from the AT24C02 data sheet
The above information contains three important points:
The word address of interest must be spelled first.
No stop bit should be sent after the word address has been written.
The slave returns the desired data after sending a read instruction.
In the control center
Activate the target power and the I2C pull-up resistors.
Enter the 7-bit slave address in the "Slave Addr" text field. Remember that when sending an instruction, the Aardvark will automatically use the R /! W bit appends.
Activate the "No Stop" check box (the data sheet says that there should be no stop bit after the dummy write).
Write the desired memory address into the slave (in this case 0x60).
Read 1 byte from the desired location.
Control Center GUI after random reading
The Control Center transaction log above shows that byte 0xAA was stored at address 0x60.
Note: The AT24C02 automatically increases the word address after each read process. So if you press "Master Read" again, the byte will be read from address 0x61, then 0x62, and so on. As shown in the screenshot, 0xAB was saved at address 0x61.
In batch mode
The steps to perform a random read are the same regardless of the method you choose. To do this, use the following XML file in the Control Center batch mode:
<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>
I2C test and measurement tools
Having the right tools is essential when developing with I2C to save time to market and money.