Electronic – i2c automatic address assignment

addressingi2c

I have asked the question here and someone offered to ask here in order to get better answers, so here it is:

History:

I decided to design a circuit with some peripheral ic's. Although SPI
may achieve great data rates, because of its master-slave architecture
and separate chip select pin requirement, I decided to use I2C because
of its multi-master and real serial design. (SPI is not a fully serial
protocol, it's more like a hybrid protocol: serial port for data
exchange, parallel port for chip select lines)

Problem:

I've been planning to add some adc, dac, gpio ic's to a
microcontroller but these modules are produced with a few slave
addresses available. Manufacturers are embedding slave's addresses
into the ic hardware. What a bad idea! So, I have faced with the
addressing problem of i2c protocol.

Some of the ic's present address assignment pins (3 pins, which means
I would not use more than 7 of them). That's not enough in my case.

Some people offer scanning addresses from 0x00 to 0xff, but this is
not a good approach because it's time wasting (I think). Someone says
"There are i2c buffer's or i2c MUX's you may use" or even another
microcontroller for address translation (NAT like approach) but
weren't we choosing and using i2c for simplicity (like fewer routes on
board, flexibility etc) in the first place?

There are people having this address assignment problem (eg.
http://www.linkedin.com/groups/Methods-enumerating-I2C-slaves-autoassigning-4023060.S.113408032)

Suggestion:

Automatic address assignment could be done with an algorithm something
like that:

  1. Slave components would have 2 bytes of non-volatile memory in order to keep their addresses permanently.
  2. Slaves will have a default address (eg. 0x01).
  3. On power up, if slave has not been assigned with an address different from default, slaves will become master and ask for an
    address from the host (eg at address 0x00).
  4. Our actual master node (microcontroller, the host) (in this example which has "0x00" address) will act as a slave naturally, because there
    is another master on the bus and will respond (assign) next available
    address to the slave.
  5. 0x01 address will be reserved for broadcasting. Master may use this address in order to make slaves reset their assigned addresses.

That would be enough for automatic address assignment.

Yes, I know about SMbus. It has automatic address resolution protocol,
but it has other limitations (speed, timeout etc) which makes me not
want to prefer SMbus over I2C.

This address assignment protocol may be optional and could be
activated by a single pin on the ic package. So, it will be backwards
compatible.

Question:

Probably I'm not the smartest person in the universe but,

  1. is there an address assignment protocol that vendors already implement in i2c
  2. if not, what would be wrong with this protocol
  3. if nothing is wrong, why don't they possibly start implementing a protocol like this (again, I know I'm not the smartest person, so they
    should have taught about this problem and they should have already
    discovered an algorithm like this)

Best Answer

Your problem can be solved with SMBus which is logically an extension on I2C. SMBus supports an ARP, wherein it can detect multiple IC's of same address, and assign them a different address. The ARP process basically reads a UUID ( a unique id per device; all the different devices in the same lot will have a different UUID) from the slave address (there may be multiple devices on this slave address). Due to the I2C bus arbiration process, only one slave will succeed at a time, and the master successfully reads its UUID. Then the master assigns a unique address using that UUID as reference. The process is repeated until all the slaves get a resolved address.