View previous topic :: View next topic |
Author |
Message |
daveh
Joined: 30 Aug 2013 Posts: 19
|
"Safe" I2C slave address |
Posted: Tue Dec 12, 2017 3:50 pm |
|
|
Hello, I'm trying to come up with an I2C slave address to use in my product. I'd like to find something that hopefully won't interfere with future sensors I might add.
My initial approach was to find a product that I'm not likely to use and use that address. So I picked the NXP RTC PCA2129 which has an address of 0x51 since I'm already using a different RTC. After wasting too much time trying to trouble shoot my code I came to realize that is the same address as the 24LC32AT EEPROM I'm using... what are the odds.
So now I went through and recorded all of the addresses I'm currently using. I can randomly pick another number that won't interfere but I was wondering if there's any way I can be somewhat certain that I'm picking a number that I won't conflict with if I add another I2C device in the future. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Tue Dec 12, 2017 3:57 pm |
|
|
Seems Mr. Murphy has already 'got you' ! Unlike PC peripherals where ther are 65,535 different adddresses, I2C has a smaller range. There may be an offical list( I haven't checked ) of 'reserved' or 'taken' addresses.
Frankly whatever you choose next, Murphy will probably return....
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Wed Dec 13, 2017 1:54 am |
|
|
Basically the answer is no....
However if you are coding the slave, one suggestion is to use 10bit address mode.
On I2C the first byte sent carries the normal 'address'. This is coded as 7 bits plus a R/W bit. The 128 addresses this gives, then have some reserved. For example 0 ('General call'), and several other low addresses (particularly four for the 10bit mode), to give 112 useable addresses. Now think how many IC's are made, and realise just how high the probability of a clash is (only just under 1% for just two devices).
10bit mode adds a little complexity to the slave (the interrupt routine has to detect the first address byte, and then test itself for the second byte matching on the next call), but opens up a nice number of addresses that are rarely being used.
The pattern 0b1111 0xxR is reserved for this mode. The 'xx' here are the top two bits of the 10bit address, and the next byte has the remaining 8bits.
Keep the top two bits fixed. So send 0b1111 011R say, and then you have an 8 bit address range in the next byte for your device, with a really low probability of clashes. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Wed Dec 13, 2017 6:30 am |
|
|
great idea 10 bit addresses but knowing MY luck...Murphy would STILL get me
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Wed Dec 13, 2017 9:02 am |
|
|
That's the law.... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
daveh
Joined: 30 Aug 2013 Posts: 19
|
|
Posted: Wed Dec 13, 2017 3:19 pm |
|
|
Thanks guys for all your help and insights. The list from adafruit is very helpful. |
|
|
|