SLVAG35 August   2026 BQ78702B , BQ78706 , BQ79718B-Q1 , BQ79731B-Q1

 

  1.   1
  2.   Abstract
  3. 1Introduction to I2C Features for AFE and BJB
  4. 2I2C Hardware Overview for AFE and BJB
  5. 3Hands-On Practice with I2C Communication Commands
    1. 3.1 EEPROM Write Operation
    2. 3.2 EEPROM Read Operation
      1. 3.2.1 Reading One Byte from Any Register Address
      2. 3.2.2 Continuously Reading Multiple Bytes from Any Address
  6. 4Conclusion
  7. 5References

EEPROM Write Operation

Case 1: Write 0x00, 0x01, 0x02, 0x03, 0x04, and 0x05 into the address range 0x0000~0x0004 of the EEPROM with device ID 000.

The write command consists of three parts: Device ID, Register Start Address, and Data to be written.

 EEPROM Write Command ProtocolFigure 3-1 EEPROM Write Command Protocol

Device ID: TARGET ADDR

According to address definitions in EEPROM datasheets, the vast majority of EEPROM address definitions are as follows:

The device type is fixed at 0b1010. The device address is determined by the pin logic states of A2~A0. Bit0 is 0 for write operations and 1 for read operations.

Table 3-1 EEPROM Device ID Definition
Device Type Identifier Device Address Bits R/W̅
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
1 0 1 0 A2 A1 A0 R/W̅

Take the following figure as an example:

For write operations, ROM0 address is 0xA0 (0b1010 0000), and ROM1 address is 0xA2 (0b1010 0010)

For read operations, ROM0 address is 0xA1 (0b1010 0001), and ROM1 address is 0xA3 (0b1010 0011)

 EEPROM Address DiagramFigure 3-2 EEPROM Address Diagram

Register start address REG ADR H/L:

Writing can start from any address, but consecutively written bytes cannot exceed the length of one Page. After knowing the start address, the EEPROM automatically increments the address by 1 for each byte written before writing the next byte. However, the address does not accumulate across pages; otherwise, an address roll-over issue will occur. If the number of written bytes exceeds the remaining space of the current page, the address counter may automatically "roll over" to the beginning of that page, accidentally overwriting previously written data.

Page sizes vary across different ICs; searching for "byte page" in the datasheet reveals the page size. For example, with a 32byte-page, starting from the page start location 0x00 allows writing up to 32bytes consecutively. If writing starts from the page end location 0x1F, only one byte can be written.

 Register address automatically increments to the bottom of the page and automatically rolls over to the page start locationFigure 3-3 Register address automatically increments to the bottom of the page and automatically rolls over to the page start location

When writing large amounts of data across page boundaries, the data must be split into multiple write commands. An interval of >5ms is required between write commands, as specified in the EEPROM datasheet: Self-Timed Write Cycle within 5ms Maximum. This time is dedicated to a complex internal routine involving EEPROM erasure, charge pump boosting, data writing, and verification.

Below are the commands for writing 6 consecutive bytes


# 使能I2C,将GPIO0和GPIO1设置为SCL和SDA.
B0 03 0A 05 10 47
# I2C_WR_DATA写设备ID 0xA0 。I2C_CTRL写0x29,SEND-START-I2C_GO
B1 03 70 A0 29 E0 5B
# ADDH=00.  SEND-I2C_GO
B1 03 70 00 21 99 9D
# ADDL=00. SEND-I2C_GO
B1 03 70 00 21 99 9D
#写1~5个字节 
B1 03 70 00 21 99 9D
B1 03 70 01 21 98 0D
B1 03 70 02 21 98 FD
B1 03 70 03 21 99 6D
B1 03 70 04 21 9B 5D
# 写最后一个字节, SEND-STOP-I2C_GO
B1 03 70 05 25 9B 0E
# 读故障寄存器,检查I2C_LOW和I2C_NACK是否有故障。
A0 05 3D 00 22 B5

Inputting the above commands into the TI EVM host GUI executes an I2C communication; the figure below shows the communication data recorded by a logic analyzer.

 Logic Analyzer Data Analysis for I2C Transmission of A0Figure 3-4 Logic Analyzer Data Analysis for I2C Transmission of A0