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)
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)
Automatic address assignment could be done with an algorithm something like that:
- Slave components would have 2 bytes of non-volatile memory in order to keep their addresses permanently.
- Slaves will have a default address (eg. 0x01).
- 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).
- 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.
- 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.
Probably I'm not the smartest person in the universe but,
- is there an address assignment protocol that vendors already implement in i2c
- if not, what would be wrong with this protocol
- 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)