Uncategorized

i2c address discuission

1

Without getting into the specifics of the project, I have a situation where I’m having to electronically add and remove devices from the I2C bus due to addressing concerns. If I can just isolate one line (SDA) instead of both (SDA and SCL) it reduces the complexity and hardware costs.

The scenario (simplified) is I have enough I2C devices that they begin to share addresses. I’m hoping to electronically isolate them into banks and switch between the banks electronically. I was planning on leaving the clock line communicating to all devices, and only worry about switching based on the SDA line.

The question is: does the addressing information travel exclusively over SDA, and thus will isolating just the SDA line be enough to avoid address conflicts?

  • 1
    Without giving this a great deal of thought I’d remove the clock rather than the data. Why not just use an I2C bus multiplexor such as the TCA9548A, which exists to cater for address clashes? – joan Feb 14 ’17 at 18:37

2 Answers

1

There are two I2C busses on the RPI. Bus 1 using pins 3 & 5 and Bus 0 using pins 27 & 28. If you are not using a hat with a EEPROM, I believe you can use Bus 0 for additional devices. This may simplify your problem.

-1

The direct answer to your question is that the address is encoded only on the SDA line. The SCL line tells devices when to check the level on SDA, but it carries no other data, including the address data.

But if you let one block of devices see the SCL line alternating while “disconnected” from the SDA bus in some way, those devices will still register the clock signals and read from their SDA pins. What they read will depend on what exactly you did to “disconnect” the SDA bus from that block. Could be high, low, or essentially random depending on what you did. So even though no address information is carried on SCL, you may still have your “disconnected” block of devices responding.

As noted in the comment by Joan, there are external ICs that can be used to change the apparent address of devices on a bus. That may be a better solution for you.

Edit

The comments seem to be vandalism at this point. Lest someone come along later and be confused by them, the schematic below illustrates the issue. The OP doesn’t specify how or where he planned to disconnect. If SW2 is closed but SW1 is open, that would disconnect SDA from anything in the box. In that case the pull-up will keep the data pins on anything in the box high, and as the clock alternates, each device will read a high bit. If SW2 is open but SW1 is closed, that would also disconnect SDS from anything in the box. But now the data pins are not pulled-up and may take any state depending a on variety of factors including what’s in the box (e.g. is there another point where the line is pulled-up?), how ideal the switch is, etc.

If there’s confusion, perhaps it’s that both the Pi (the master) and the devices in the box (the slaves) have SDA pins. The master’s pin ultimately needs to be connect to a pull-up for the protocol to work. That’s distinct from what happens on the slaves.

schematic

simulate this circuit – Schematic created using CircuitLab

  • “So even though no address information is carried on SCL, you may still have your “disconnected” block of devices responding.” – I think this statement is incorrect and misleading. – tlfong01 Jun 5 at 0:12   
  • In what way is in incorrect? Each time the SCL line cycles, every device reads its own data pin. That’s the whole system. – Brick Jun 5 at 0:34
  • You said the following – “What they read will depend on what exactly you did to “disconnect” the SDA bus from that block. Could be high, low, or essentially random depending on what you did.” The point is that SDA line disconnected I2C device still has its SDA pin pulled high to Vcc. So it will always read High. – tlfong01Jun 5 at 0:43   
  • It depends on where the circuit is broken relative to the point where the pull-up is. That was my point. If you disconnect the device from the SDA line, the SDA line is presumably pulled high, but your now-disconnect pin isn’t tied to that any more. – Brick Jun 5 at 0:45
  • Yes, this I agree, It depends on how you “disconnect”. (1) If you disconnect the SDA pin from bus’s SDA line, connect it to ground, it will read Low. (2) If connect to Vcc, then will read High, (3) If SDA pin float, it will read anything. Original NXP/TI design is all I2C devices, matter master or slave, have SDA pins pull high. This SCL/SDA pull high is the crux of the matter of design principle. I suggest you to read TI/NXP on I2C protocol first, then we can have some common ground to discuss further. (Yes, I spent more than 1,000+ hours studying and experimenting I2C stuff.) – tlfong01 Jun 5 at 1:08   
  • You might like to know how I “disconnect” I2C devices: (1) DeMultiplexing I2C Devices raspberrypi.org/forums/… (2) I2C Demultiplexor/Switch i.imgur.com/BITWxkY.jpg (3) TCA9548A 8 Channel I2C Switch ti.com/lit/ds/symlink/tca9548a.pdf (4) I2C Expander i.imgur.com/TD6VjeW.jpg (5) I2C Extender i.imgur.com/L89dhcC.jpg – tlfong01 Jun 5 at 1:15   
  • I added a schematic based on these comments, but it seems at this point that you’re just trolling. Your comments are unintelligible and not especially related to the question or the answer. – Brick Jun 5 at 1:26
  • @Bricks I very much agree with your saying that “Your comments are unintelligible”. As I said, we don’t have a common ground on electronic engineering stuff. You might like to divert my comments to electronicsEngineering.stackExchange and ask those EE professionals if my comments are incorrect or misleading. – tlfong01 Jun 5 at 1:44    

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: