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

Two I2C devices with same address, and only 1 spare pin!

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



Joined: 15 Sep 2003
Posts: 226

View user's profile Send private message

Two I2C devices with same address, and only 1 spare pin!
PostPosted: Thu Feb 08, 2007 11:11 am     Reply with quote

Sometimes it's difficult to use I2C devices when the address is hard coded in the chip.
I need to use to chips that have no means of setting the address. In a different design I simply used two (soft) I2C ports.

The current project needs the same two chips and to complicate the issue I only have one spare pin.
So making the second I2C port is not possible without some juggling.

Sharing the SDA pin should work, if I remember correctly the SCL wakes up the chips.

Has anyone done this?
Did it work and are there issues to watch out for ?

Thanks..

#use i2c(Master,Fast,sda=PIN_E0,scl=PIN_E1) // for chip #1

code here for access to chip #1

#use i2c(Master,Fast,sda=PIN_E0,scl=PIN_E2) // for chip #2

code here for access to chip #2
avro698



Joined: 11 Nov 2006
Posts: 9
Location: South Wales, UK.

View user's profile Send private message

PostPosted: Thu Feb 08, 2007 12:57 pm     Reply with quote

You could look at using an I2C multiplexer, try this http://www.standardics.nxp.com/products/pca/pdf/pca9543a.pca9543b.pca9543c.pdf
This would allow both IC's to exist on their own "sub bus", so address conflicts will not occur. The multiplexer will control the data traffic between master device and the selected slave peripheral.
The advantage here is that you do not use any extra pins, the switching is done using I2C commands.
The overhead is that you must provide extended code to actually perform the switch between the two sub devices.


Hope this is of help

ATB 698
Hans Wedemeyer



Joined: 15 Sep 2003
Posts: 226

View user's profile Send private message

Thanks but this time not enough space for more chips!
PostPosted: Thu Feb 08, 2007 2:39 pm     Reply with quote

avro698 wrote:
You could look at using an I2C multiplexer, try this http://www.standardics.nxp.com/products/pca/pdf/pca9543a.pca9543b.pca9543c.pdf
This would allow both IC's to exist on their own "sub bus", so address conflicts will not occur. The multiplexer will control the data traffic between master device and the selected slave peripheral.
The advantage here is that you do not use any extra pins, the switching is done using I2C commands.
The overhead is that you must provide extended code to actually perform the switch between the two sub devices.


Hope this is of help

ATB 698
adrian



Joined: 08 Sep 2003
Posts: 92
Location: Glasgow, UK

View user's profile Send private message

Re: Two I2C devices with same address, and only 1 spare pin!
PostPosted: Fri Feb 09, 2007 6:33 am     Reply with quote

Hans Wedemeyer wrote:


#use i2c(Master,Fast,sda=PIN_E0,scl=PIN_E1) // for chip #1

code here for access to chip #1

#use i2c(Master,Fast,sda=PIN_E0,scl=PIN_E2) // for chip #2

code here for access to chip #2


what would happen if you swapped it around so that you had a common clock and sepatate data paths?
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Feb 09, 2007 6:59 am     Reply with quote

Or, just brainstorming, use the extra pin to activate a cheap 74xx-series external multiplexer which switches the CLK and SDA lines. This way you can create two totally separated I2C busses served by a single (hardware) master.

Code:
select --------
              | 
           -------
           |multi|------- SDA_1
           |plex |------- CLK_1
           |     |
 sda ------|     |
 clk ------|     |------- SDA_2
           |     |------- CLK_2
           -------
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Fri Feb 09, 2007 8:45 am     Reply with quote

I think he said that he has no room for more chips.((in the subject line))
what if these are software I2C?
and you revese clock and data on one of the chips.
that way, at one time B1-->clk b2-->sda
then when talking to other chip
B2-->clk and B1-->data.

? ? ? Any chance that would work??
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Fri Feb 09, 2007 10:13 am     Reply with quote

I've had to do something similar to this. I had four sensors with the same hard coded address that I wanted to connect to the same I2C bus. I used a SN74CBT3253 mux chip for this. It will mux one bus with four devices. S0 & S1 are the pins used to select which channel you want to use. If you only have one spare pin, on your PIC, you could tie S1 to GND and simply toggle S0 for which device you wanted to talk to. Simply set or clear S0 before you start your I2C communications routine.

Since the inactive channel will be disconnected from the I2C bus you will need to make sure that each Slave has pull-ups on each side of the mux chip, ie. pull-ups on the PIC side and pull-ups on each of the Slave's bus. If you don't do this the Slave will see a clock pulse when that channel is disconnected and reconnected. They come in surface mount and are rather small in size.

Ronald
Donlaser



Joined: 17 Sep 2005
Posts: 12
Location: Trenque Lauquen, Argentina

View user's profile Send private message MSN Messenger

PostPosted: Fri Feb 09, 2007 11:07 am     Reply with quote

I use a scheme similar to the proposed one by Adrian to control two TDA7449 i2c audio preamp with two data lines and a data line for the shared clock.
Ttelmah
Guest







Re: Two I2C devices with same address, and only 1 spare pin!
PostPosted: Fri Feb 09, 2007 11:24 am     Reply with quote

adrian wrote:
Hans Wedemeyer wrote:


#use i2c(Master,Fast,sda=PIN_E0,scl=PIN_E1) // for chip #1

code here for access to chip #1

#use i2c(Master,Fast,sda=PIN_E0,scl=PIN_E2) // for chip #2

code here for access to chip #2


what would happen if you swapped it around so that you had a common clock and sepatate data paths?


I think this is the correct way to go.
I you look at the I2C spec. the key thing for this appplication, is that the second slave, must _not_ see a start or a stop condition. Now in I2C, both of these conditions are defined by transitions on the _data_ line, with different clock states. If the data line does not transition, the device cannot see a start, or a stop condition, and will therefore never respond.
It appears then, that this should be the right solution.

Best Wishes
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