CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

"Safe" I2C slave address

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
daveh



Joined: 30 Aug 2013
Posts: 19

View user's profile Send private message

"Safe" I2C slave address
PostPosted: Tue Dec 12, 2017 3:50 pm     Reply with quote

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: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Dec 12, 2017 3:57 pm     Reply with quote

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.... Laughing

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Wed Dec 13, 2017 1:54 am     Reply with quote

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: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Dec 13, 2017 6:30 am     Reply with quote

great idea 10 bit addresses but knowing MY luck...Murphy would STILL get me Laughing
Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Wed Dec 13, 2017 9:02 am     Reply with quote

That's the law....
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 13, 2017 10:51 am     Reply with quote

Based on this list from Adafruit, I would pick 0x66 (7-bit format) as
a suitable i2c slave address:
https://cdn-learn.adafruit.com/downloads/pdf/i2c-addresses.pdf
That translates to 0xCC in CCS format.
daveh



Joined: 30 Aug 2013
Posts: 19

View user's profile Send private message

PostPosted: Wed Dec 13, 2017 3:19 pm     Reply with quote

Thanks guys for all your help and insights. The list from adafruit is very helpful.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group