I2C SPI USB CAN eSPI Cable Testing View All Videos Quick Start Guides Software Downloads App Notes White Papers User Manuals Knowledge Base Sales Support About Us
Products Blog Sales Support Contact Search
Programming I2C EEPROM using Aardvark Adapter and Control Center Serial Batch Mode on Linux Ubuntu 14 04 64 bit
Programming I2C EEPROM using Aardvark Adapter and Control Center Serial Batch Mode on Linux Ubuntu 14.04 64 bit

Introduction

Programming and reading I2C memory devices is a common use case for the Aardvark I2C/SPI Host Adapter. There are several ways to do this with the Aardvark adapter, including using Control Center Serial, Flash Center, or the Aardvark API. This article focuses on how to take the information in an EEPROM datasheet and execute the commands in Control Center Serial Batch mode. Although the following describes the AT24C02 I2C EEPROM found on the I2C/SPI Activity Board, similar steps can be used for other devices. The goal of this article is to demonstrate how to write several bytes to a specific address and then read back those bytes on Linux Ubuntu 14.04 64 bit.

Overview

In this article the Aardvark adapter is the I2C master and the Atmel I2C EEPROM AT24C02 on the I2C/SPI activity board is the I2C slave.

AT24C02 Detailed

In this article, the AT24C02 SCL (Serial Clock Input) and SDA (Serial Data) signals are connected to the Aardvark adapter SCL and SDA signals accordingly. The AT24C02 A0 - A2 (Address Input), WP (Write Protect) and GND (Ground) signals are connected to ground. The AT24C02 VCC (Power Supply) signal is connected 3.3V.

Figure 1: AT24C02 Pinouts

The AT24C02 I2C EEPROM on the activity board has a hardware configurable I2C target address. The default I2C target address is 1010000b, which is 0x50. This article uses the default I2C target address 0x50. For additional information take a look at knowledge base article 7-bit, 8-bit, and 10-bit I2C Slave Addressing.

The AT24C02 on the I2C/SPI activity board receives the I2C pulls-ups and power from the Aardvark adapter. In order to supply the I2C pull-ups and target power to the Activity board, the Aardvark adapter and Control Center Serial are configured with the batch command "configure" to I2C/SPI mode (i2c="1" spi="1" gpio="0"), I2C pull-ups enabled (pullups="1"), and target power enabled (tpower="1"). For additional information take a look at the I2C/SPI activity board user's manual.

The AT24C02 write operation used here is Page Write. The Page Write operation to the AT24C02 requires 7 bit device address, one byte memory address, and two or more bytes of memory data. Performing a memory write operation with the Aardvark adapter requires a single command from the adapter and Control Center Serial. In this case, Control Center Serial batch mode example "i2c-eeprom-write" is used in order to perform 256 "i2c_write" commands of data 0x00 - 0xFF to memory addresses 0x00 to 0xFF with I2C device address 0x50. For example, take a look at the first and last i2c_write commands.

<i2c_write addr="0x50" count="2" radix="16">00 00</i2c_write> 
<i2c_write addr="0x50" count="2" radix="16">FF FF</i2c_write> 

The first command includes the device address (addr="0x50"), number of data bytes (count="2"), data format (radix="16"), memory address (0x00), and memory data (0x00). While the last "i2c_write" command includes the I2C device address (addr="0x50"), number of data bytes (count="2"), data format (radix="16"), memory address (0xFF), and memory data (0xFF).

Figure 2: AT240C Page Write

The AT240C read operation used here is the Sequential Read. The AT240C Sequential Read operation first performs I2C write with 7 bit device address, one byte memory address and no stop. Then the AT240C Sequential Read operation performs I2C read with 7 bit device address, two or more bytes of memory data, and stop. Performing a memory read operation with the Aardvark adapter requires two commands from the adapter and Control Center Serial batch mode. In this case, Control Center Serial batch mode example "i2c-eeprom-read" is used in order to perform read of 256 bytes from address 00 with I2C device address 0x50. In this article the memory read operation includes the following two Aardvark adapter and Control Center Serial batch mode commands:

<i2c_write addr="0x50" count="1" radix="16" nostop="1">00</i2c_write> 
<i2c_read addr="0x50" count="256"/> 
  1. The first command is "i2c_write" including the I2C device address (addr="0x50"), number of data bytes (count="1"), data format (radix="16"), memory address (0x00), with no stop (nostop="1"). This write command is for configuring the internal data word address counter to a specific address (0x00).
  2. The second command is "i2c_read" including the I2C device address (addr="0x50") and the number of the data bytes (count="256"). This read command is to read the data starting from address 0x00.

For additional information take a look at the AT24C02 datasheet.

Figure 3: AT240C Sequential Read

Writing and Reading Guidelines

      1. Connect the Aardvark adapter to the PC via the USB connector.
      2. Download the latest version of the Total Phase USB Drivers Installer for Linux.
      3. Follow the instructions in Section 3.3 - Linux USB Driver of the Aardvark adapter user manual to install the Linux USB drivers using the UDEV option. The 99-totalphase.rules file can be found in the latest version of the Total Phase USB Drivers Installer for Linux.
      4. Install the required packages.
        1. Install the latest libusb drivers for 32 bit: (Make sure you enter the full name of the latest libusb drivers for 32 bit)
          1. sudo apt-get install libusb*
        2. Install 3 additional packages:
          1. sudo apt-get install libc6:i386 zlib1g:i386 \
          2. libstdc++6:i386 libgtk2.0-0:i386 libpango1.0-0:i386 \
          3. libxxf86vm1:i386 libsm6:i386
        3. Use the tool "strace", and verify if any 32 bit libraries are missing, and then install the missing libraries.
      5. Download and unzip the latest version of Control Center Serial. (?)
      6. Connect the Aardvark adapter to the I2C/SPI activity board via the I2C/SPI connector. (?)
      7. Launch Control Center Serial. (?)
      8. Connect to the Aardvark adapter. (?)
        1. Click Configure Adapter.
        2. Select the Aardvark Adapter.
        3. Click OK to connect to the adapter.
      9. Click Adapter, and choose Batch Mode.
      10. Write to the memory (?)
        1. Click Load, and choose i2c-eeprom-write.
        2. Click Open, and Execute.

        Figure 4: Aardvark Adapter Writes 256 Bytes To AT24C02

      11. Read from the memory (?)
        1. Click Load, and choose i2c-eeprom-read.
        2. Click Open, and Execute.

        Figure 5: Aardvark Adapter Reads 256 Bytes From AT24C02

Notes

For additional information, take a look at the Aardvark adapter user manual, I2C/SPI activity board user's manual and Control Center Serial manual.