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
How Do I Write to Multiple Registers of I2C EEPROMs?
Rena Ayeras

Image of man trying to view data that was collected but not accessible Image by Mikhail Nilov via Pexels
Question from the Customer:

I am using the Aardvark I2C/SPI Host Adapter with Control Center Serial Software. I want to write to multiple registers of I2C EEPROMs. I found one option: Master Write. However I could use more details – what is the format to write to the register first and then data?

Here is a screen shot showing the transactions that occur:

Response from Technical Support:

Thank you for your question! Because you are writing to multiple registers, we recommend using batch mode to automate your process. To help you set up your script, we will first discuss how Register Write works, and then provide an overview of batch commands.

Register Write

The Register Write function can be completed with a single write command when the Aardvark adapter is the master I2C device. Acknowledgements will be expected from the slave device.

For example, to write the data 04 19 to the register location 0x12, you can usually do so by entering the following command through Control Center Serial Software the message window:

12 04 19

That is a typical format, in which the first byte is the register or memory address, followed by data. In some cases, the first two bytes are the memory address of the device. The datasheet of your target EEPROM should provide the details of the read/write protocol of that device.

Read/Write Pointers

The smallest EEPROM chips are usually implemented with a single read/write pointer. In this case, the first byte of any write operation sets this pointer.

All of the subsequent read or write operations start from that location. When any single byte is implemented, the pointer is automatically incremented. This simplifies writing consecutive bytes to the EEPROM. A single Master Write function can write 4 bytes of data to the EEPROM as shown below:

<start> <i2c_addr> <mem_addr> <byte1> <byte2> <byte3> <byte4> <i2c stop>

  1. These 5 bytes of data payload writes 4 bytes to EEPROM starting at mem_addr.
  2. Once complete, the internal pointer is at byte5, so if you issued an immediate subsequenti2c read you would get byte

This Master Register Read function of the Control Center Serial Software is a shortcut of the above operation. The same result can be achieved by using Master Write followed by Master Read. For more information, refer to the KB Article  How to Read and Write to an I2C EEPROM Using the Aardvark Adapter and Control Center. This document provides step-by-step guidelines and visual examples of how it looks in the Control Center Serial Software dialog windows.

Automate Register Write/Read with Batch Commands

You can script XML batch commands to automate your process. For details, refer to the article Control Center Serial Software Series: XML Batch Scripting for Automated Tasks. Examples of batch commands include reading and writing to a target device, reading registers of a device, as well as how to implement batch scripts.

To develop more customized programs, the Aardvark Software API is available, which is provided with functional scripts that you can use as is, or modify as needed for your setup.

We hope this answers your question. Additional resources that you may find helpful include the following:

If you want more information, feel free to contact us with your questions, or request a demo that applies to your application.