0
\$\begingroup\$

The I2C specification says the addressed target device responds to the 7 or 10 bit target address. And the data transfer is always in 8 bits. Then, does it mean all the I2C target devices just provide one byte data? If I want to access for example 4 32-bit registers using I2C, and if my target device has the target address for example 0x34, how can I read/write the registers? The specification doesn't clearly mention about this.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Get the data sheet for any i2c eeprom and it will explain how this is handled. \$\endgroup\$
    – The Photon
    Commented Jun 27, 2022 at 5:41
  • \$\begingroup\$ @ThePhoton That would be a bad example, because an I2C EEPROM technically is specifically not a register based device, but also a good example because it is one more variety of a protocol how to access a chip via I2C bus, and there are also multiple different addressing schemes for different EEPROMs. \$\endgroup\$
    – Justme
    Commented Jun 27, 2022 at 5:49

1 Answer 1

5
\$\begingroup\$

The specification only defines how to talk to a device, reading and writing bytes to it.

The specification does not define what the bytes mean. It is up to your chips to define the protocol at byte level.

Some chips don't have any registers so they have just single data byte.

Some chips don't have any registers but you send command packets to it and read response packets.

Some chips have registers. Some chips have 8-bit register addresses so they use one byte of index, some chips have 16-bit register addresses so they use two bytes of index.

And depending on chip, the registers may be 8, 16, 24 or 32 bits long.

So how to use a specific chip is in the chip data sheet, not in I2C specifications.

\$\endgroup\$
2
  • \$\begingroup\$ Hi, now that's clear to me. I checked a document on I2C by Texas Instrument and it showed register address phase after the device address phase. So like you said, I understand the byte sequence format depends on the device (and I guess the I2C master should know how the devices have different addressing capability even on the same board?). \$\endgroup\$
    – Chan Kim
    Commented Jun 27, 2022 at 7:36
  • 1
    \$\begingroup\$ @ChanKim It's more a job of the programmer to construct correct byte transactions on the bus, the I2C peripheral just sends or receives bytes in the transactions. \$\endgroup\$
    – Justme
    Commented Jun 27, 2022 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.