I2c Address Assignment Behavior

We often get inquiries from our customers about what slave address to use in order to communicate with their I2C slave device. Unfortunately a lot of this confusion stems from the fact that different vendors follow different slave address conventions.

The goal of this article is to clarify the slave address standard used by all Total Phase products and to help developers determine what slave address they should use.

Contents


The I2C specification from NXP (formerly Philips) actually specifies two different slave addressing schemes. Standard Mode I2C makes use of 7-bit addressing. 10-bit addressing was later added as an extension to standard mode I2C.

7-bit Addressing

In 7-bit addressing procedure, the slave address is transferred in the first byte after the Start condition. The first seven bits of the byte comprise the slave address. The eighth bit is the read/write flag where 0 indicates a write and 1 indicates a read.

Figure 1: 7-bit addressing. The I2C bus specification specifies that in standard-mode I2C, the slave address is 7-bits long followed by the read/write bit.

All I2C products from Total Phase, follow this standard convention. The slave address used should only be the top seven bits. In the case of the Aardvark I2C/SPI Host Adapter, the software will automatically append the correct read/write bit depending on the transaction to be performed. In the case of the Beagle I2C/SPI Protocol Analyzer, the slave address and the type of transaction are displayed in two different columns.

Reserved Addresses

The I2C specification has reserved two sets of eight addresses, 1111XXX and 0000XXX. These addresses are used for special purposes. The following table has been taken from the I2C Specifications (2000).

Slave AddressR/W BitDescription
General call address
START byte(1)
CBUS address(2)
Reserved for different bus format(3)
Reserved for future purposes
Hs-mode master code
10-bit slave addressing
Reserved for future purposes

(1) No device is allowed to acknowledge at the reception of the START byte.

(2) The CBUS address has been reserved to enable the inter-mixing of CBUS compatible and I2C-bus compatible devices in the same system. I2C-bus compatible devices are not allowed to respond on reception of this address.

(3) The address reserved for a different bus format is included to enable I2C and other protocols to be mixed. Only I2C-bus compatible devices that can work with such formats and protocols are allowed to respond to this address.

8-bit Addresses

Some vendors incorrectly provide 8-bit addresses which include the read/write bit. Often times, you can determine if this is the case because they will provide one address for writing to the slave device and another to reading from the slave. In this situations. please only use the top seven bits of the address.

Figure 2: 8-bit addresses. Some vendors incorrectly provide two 8-bit slave addresses for their device, one to write to the device and one to read from the device. This 8-bit number actually encodes the 7-bit slave address and the read/write bit. Since Total Phase's products use 7-bit addressing, it is important to only use the top 7 bits of the address as the slave address.

Another way to determine if a vendor is using 8-bit addresses instead of 7-bit addresses is to see if the slave address falls within the correct range. All 7-bit addresses should be greater than 0x07 and less than 0x78 (120). If your slave address is outside this range, chances are your vendor has specified an 8-bit address.

Figure 3: Valid 7-bit Slave Address Range. The range of valid 7-bit slave addresses are bound by two blocks of reserved addresses at either end of the range. Valid slave addresses are greater than 0x07 and less than 0x78.

10-bit Addressing

One of the reasons that Total Phase decided to use 7-bit addressing for all of its products was to ensure that 10-bit addressing could be properly handled.

10-bit addressing was designed to be compatible with 7-bit addressing, allowing developers to mix two types of devices on a single bus. When communicating with a 10-bit addressed device, the special reserved address is used to indicate that 10-bit addressing is being used.

Figure 4: 10-bit addressing. In 10-bit addressing, the slave address is sent in the first two bytes. The first byte begins with the special reserved address of 1111 0XX which indicates that 10-bit addressing is being used. The 10 bits of the address is encoded in the last 2 bits of the first byte and the entire 8 bits of the second byte. The 8th bit of the first byte remains the read/write flag.

If a 10-bit address is specified when using the Aardvark I2C/SPI Host Adapter, its software will take care of sending the correct bits. The developer does not need to perform any special steps to send the correct address data. The Beagle I2C/SPI Protocol Analyzer will also automatically detect 10-bit slave addresses in the captured data and display the information correctly.

References

First, don't use 0x00 and 0x01, those are reserved! Table 3 of the I2C Bus Specification lists the reserved addresses (and reasons why):

Slave addr R/W Description 0000 000 0 General call address[1] 0000 000 1 START byte[2] 0000 001 X CBUS address[3] 0000 010 X Reserved for different bus format[4] 0000 011 X Reserved for future purposes 0000 1XX X Hs-mode master code 1111 1XX X Reserved for future purposes 1111 0XX X 10-bit slave addressing

You should also steer clear of 0x00 because that has no edge transitions, and might be an error condition (and it's hard to debug).

Other than that, I'd say "Just make it configurable." If you want to be able to plug in a wide variety of sensors, then you can either pay NXP for an address, or give it adjustable addresses. Software modifications should be obvious if you want to distribute the source code. A hardware option to toggle one or two bits of your selected address (solder jumpers on digital pins) is cheap and easy, or a ladder network of resistors with jumpers connected to an A/D pin could give you complete control in the hardware.

Categories: 1

0 Replies to “I2c Address Assignment Behavior”

Leave a comment

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *