View previous topic :: View next topic |
Author |
Message |
Hans Wedemeyer
Joined: 15 Sep 2003 Posts: 226
|
Two I2C devices with same address, and only 1 spare pin! |
Posted: Thu Feb 08, 2007 11:11 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
avro698
Joined: 11 Nov 2006 Posts: 9 Location: South Wales, UK.
|
|
Posted: Thu Feb 08, 2007 12:57 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Hans Wedemeyer
Joined: 15 Sep 2003 Posts: 226
|
Thanks but this time not enough space for more chips! |
Posted: Thu Feb 08, 2007 2:39 pm |
|
|
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 |
|
|
![](templates/subSilver/images/spacer.gif) |
adrian
Joined: 08 Sep 2003 Posts: 92 Location: Glasgow, UK
|
Re: Two I2C devices with same address, and only 1 spare pin! |
Posted: Fri Feb 09, 2007 6:33 am |
|
|
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? |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Feb 09, 2007 6:59 am |
|
|
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
-------
|
|
|
![](templates/subSilver/images/spacer.gif) |
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Fri Feb 09, 2007 8:45 am |
|
|
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?? |
|
![](templates/subSilver/images/spacer.gif) |
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Fri Feb 09, 2007 10:13 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Donlaser
Joined: 17 Sep 2005 Posts: 12 Location: Trenque Lauquen, Argentina
|
|
Posted: Fri Feb 09, 2007 11:07 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
Re: Two I2C devices with same address, and only 1 spare pin! |
Posted: Fri Feb 09, 2007 11:24 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
|