3
\$\begingroup\$

Since the slave addresses are 7 bits long, why is it that the number of slaves can be only 127? Is one of the addresses reserved for some special purpose?

\$\endgroup\$
  • \$\begingroup\$ There are in fact 16 reserved addresses out of the possible 128. Addresses 000 0XXX are reserved as are 111 1xxx. The zero address is "general call". \$\endgroup\$ – Kaz Nov 5 '13 at 4:53
  • \$\begingroup\$ I see, thanks. Also found this useful link : i2c-bus.org/addressing \$\endgroup\$ – Codename Nov 5 '13 at 5:02
  • \$\begingroup\$ Also, just figured out what I actually wanted to know, the address 0000 000 is sent on the SDA line during the start sequence, so sending it again would be like resending the start sequence. \$\endgroup\$ – Codename Nov 5 '13 at 5:05
3
\$\begingroup\$

From NXP document UM10204, "I2C-bus specification and user manual", section 3.1.12, "Reserved addresses":

Two groups of eight addresses (0000 XXX and 1111 XXX) are reserved [...]

This leaves only 112 addresses available. However, it continues:

If it is known that the reserved address is never going to be used for its intended purpose, a reserved address can be used for a slave address.

So technically you can have 128 slave devices if you are architecting all the slaves yourself, but in a general system you should not assume that any of the reserved addresses are available.

\$\endgroup\$
  • \$\begingroup\$ But you still cant use 0000 000 right? Since it is same as the start sequence. So shouldn't it be 127? \$\endgroup\$ – Codename Nov 5 '13 at 5:07
  • \$\begingroup\$ @Dez: If you're following the rest of the standard strictly, yes. \$\endgroup\$ – Ignacio Vazquez-Abrams Nov 5 '13 at 6:09
1
\$\begingroup\$

Actually, most I2C devices cannot take any I2C address. They usually have a fixed address. Some can have an address chosen in a reduced set, usually less than 16 possibilities. In that case, the device address is chosen at design time by driving a few dedicated pins, for instance: Microchip temperature sensor MCP9804, chapter 3.1

http://ww1.microchip.com/downloads/en/DeviceDoc/22203C.pdf

So at the end of the day, the size of the I2C address space is not really important.

\$\endgroup\$
1
\$\begingroup\$

The LSB in the byte is used as a R/W-flag, leaving 7 bits for addressing. This allows for 127 slaves (check with @Ignacio Vazquez-Abrams why this is not necessarily entirely true) + "general call address 0000 0000". The general call adrress is used to "broadcast" to all devices on the bus.

From NXP document UM10204, "I2C-bus specification and user manual", section 3.1.13 "General call address".

The general call address can for example be used for a software reset (3.1.14).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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