3
\$\begingroup\$

I have a charging IC which I want to use with I2C. In the datasheet on page 31 it says that the I2C slave address is 6BH. Shouldn't this be a 7-bit binary number?

\$\endgroup\$
10
  • 10
    \$\begingroup\$ And how many bits does a 6B have? \$\endgroup\$ Commented Aug 1, 2021 at 18:32
  • 13
    \$\begingroup\$ 6B = 1101011 needs only 7 bits to represent it. Btw, 10-bit addresses are also sometimes used. \$\endgroup\$
    – Mitu Raj
    Commented Aug 1, 2021 at 18:33
  • 16
    \$\begingroup\$ The "H" just indicates it's a hex number. 6BH == 0x6B. \$\endgroup\$ Commented Aug 1, 2021 at 18:35
  • 9
    \$\begingroup\$ "H" - short form of "hexadecimal" when discussing numbers with various bases. \$\endgroup\$
    – JRE
    Commented Aug 1, 2021 at 18:35
  • 12
    \$\begingroup\$ Curses! curses on i2c folks who've caused so much confusion by concatenating the read/write bit with 7-bit address. \$\endgroup\$
    – glen_geek
    Commented Aug 1, 2021 at 18:48

3 Answers 3

24
\$\begingroup\$

The address 6BH can be written with just 7 bits, as binary 1101011.

The fact that a number is written in hexadecimal does not necessarily imply that it must be expressed using an integer multiple of 4 bits.

\$\endgroup\$
21
\$\begingroup\$

No, it really shouldn't. Or in fact, it depends who you ask, as it is a matter of opinion and depends on manufacturer and people who write code how they want to represent the I2C address.

Basically, there are two different notations:

  • 7-bit notation, with 7-bit value, which does not include the read/write bit
  • 8-bit notation, with 8-bit value, that contains the read/write bit.

The I2C specification always uses the 7-bit notation, where read/write bit is not part of the value. Some follow this notation.

For practical reasons, many follow the 8-bit notation, as that's what the 8-bit byte is on the bus, and what is written to 8-bit data register to transmit it, and so on. Sometimes the read address and write address are given separately, which is a definite sign of 8-bit addressing used.

So what this means is that when you are reading a chip datasheet and using MCU code to interface the chip, that sometimes addresses are used as 7-bit notation and sometimes in 8-bit notation, so you need to sometimes convert the notation to access the chip. It does not change the address or the bit pattern in any way, it's just how you look at the bits.

It is hard to see from the datasheet, if 0x6B is used as a 7-bit or 8-bit address, but the protocol diagrams indicate that 0x6B is the 7-bit address as the read/write bit is separate in the transactions.

\$\endgroup\$
4
  • \$\begingroup\$ The read and write at two different addresses in 8-bit notation has fooled me up more than once. \$\endgroup\$ Commented Aug 1, 2021 at 22:33
  • \$\begingroup\$ Also: some manufacturer say that their part has two address (which are simply the read/write part variant of the same). I guess the official notation is the NXP/Philips one, 7 bin plus RW bit. Otherwise handling the 10 bit addressing would be even more complex \$\endgroup\$ Commented Aug 2, 2021 at 6:16
  • 2
    \$\begingroup\$ if "The I2C specification always uses the 7-bit notation" then I think we should say that yes, indeed, it really should be a 7-bit number. (Which still doesn't mean that some might give a different answer, just that they're the ones who are wrong.) \$\endgroup\$
    – ilkkachu
    Commented Aug 2, 2021 at 10:18
  • \$\begingroup\$ So in 8-bit the addresses would be D6 and D7? \$\endgroup\$
    – AndreKR
    Commented Aug 3, 2021 at 2:32
10
\$\begingroup\$
Hex 7-bit hex Binary
6B 6B 110 1011
\$\endgroup\$

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.