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.
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.
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.
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 Address||R/W Bit||Description|
|General call address|
|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.
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.
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.
Every slave device, connected to the I2C bus, must have an unique I2C address. The I2C address can be either 7-bits or 10-bits long.
You can specify the I2C address in parameter when you call DlnI2cMasterWrite() or DlnI2cMasterRead() function.
If you use I2C slave interface of a DLN-series adapter, call DlnI2cSlaveSetAddress() to configure the I2C address. You can specify several I2C slave addresses. DLN-series adapter will respond to any of these addresses. After I2C master generates Stop Condition, DLN series adapter sends DLN_I2C_SLAVE_WRITE_EV or DLN_I2C_SLAVE_READ_EV event to your application. These events contain the I2C address in the slaveAddress field.
7-bit I2C Addressing
The first byte (immediately after the START condition) contains the I2C slave address.
The I2C address is 7-bits long. It is transmitted in the seven most significant bits (MSB). The last (eighth bit) of the I2C address byte is a data direction bit - a 'zero' indicates a transmission (I2C WRITE), a 'one' indicates a request for data (I2C READ).
You have to specify the 7-bit I2C slave address when you call the DlnI2cMasterRead() or DlnI2cMasterWrite() function. DLN-series PC-I2C adapters automatically add the direction bit. In fact the provided I2C address is shifted left and is supplemented by 0 (for I2C write transactions) or by 1 (for I2C read transactions).
DLN-series adapters can scan the bus for I2C addresses of the connected slave devices. Call the DlnI2cMasterScanDevices() function to get the list of I2C addresses.
Some slave device vendors specify the 8-bit I2C addresses in their documentation. In fact they specify the entire address byte (I2C address + direction bit). You need to discard the least significant bit and shift this byte right to obtain the real 7-bit I2C address.
10-bit I2C Addressing
With 7-bit addressing only 112 I2C slave addresses are available. To prevent address clashes Philips Semiconductors (now NXP Semiconductors) has introduced a 10 bit address scheme. Devices with 7-bit and 10-bit addresses can be connected to the same I2C-bus.
The 10-bit address is transmitted within the first two bytes following a START condition or a repeated START condition.
Five most significant bits of the first address byte are predefined (1111 0). I2C slave devices with 7-bit addressing ignore transactions with the first byte in the form of '1111 0XXX'.
The I2C address occupies bits 5 and 6 of the first byte and the eight bits of the second byte.
The transfer direction (read or write) is specified in the eighth bit of the first byte. As in the case of 7-bit I2C address, a 'zero' indicates a transmission (I2C WRITE), a 'one' indicates a request for data (I2C READ).
Slave devices with 10-bit I2C addressing will react to a general call in the same way as slave devices with 7-bit I2C addressing. I2C master devices can transmit the 10-bit I2C address after a general call.
I2C General Call Address
The general call address is used to address all I2C slave devices simultaneously. If I2C slave device doesn't support general call addressing, it ignores this transaction and doesn't issue an acknowledgment. The I2C master devise can't determine how many slave devices acknowledge the general call address.
You can enable the I2C general call address support for I2C slave interface with the DlnI2cSlaveGeneralCallEnable() function.
Reserved I2C slave addresses
There are 16 reserved I2C addresses. These addresses corresponds to one of the two patters: 0000XXX or 1111XXX. The table below describes the purposes of the most commonly used reserved I2C addresses:
|I2C Slave Address||R/W||Bit Description|
|0000 000||0||general call address|
|0000 000||1||START byte[|
|0000 001||X||CBUS address|
|0000 010||X||reserved for different bus format|
|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 address|
The full list of I2C address assignments you can see at I2C Address Allocation Table page or i2c-address-allocation-table.pdf document.