Tuesday, 28 October 2014

digital logic - How to block/allow an i2c data signal to pass on to another device


I have three devices which I'm working on and one of them needs to control i2c communication between the other two.


Each of the devices is based on an AtMega or AtTiny chip. The Controller (based on some external input not known to either the Master or Slave) needs to be able to decide whether or not to pass on the i2c signals to the Slave.


I'm assuming you can just 'block' the data signal (no need to stop the clock signal being passed through) in some way. I've looked at devices like Single Fet Bus Switches but I wonder if that is the best way or not.


The setup looks like: Master --i2c-> Controller --i2c-> Slave



Answer



While pulling the clock line low might work for some instances, it highly depends on how the master and the slave are coded. It might result in failed arbitration attempts or freezing due to unexpected clock stretching.


There are two simple options. One, would be to connect the slave's Clock Line, through a transistor, as you would a simple level translating setup. But instead of connecting the transistor to always on, on a different voltage, the base will be connected to your controller's enable pin. If on, the SCL line is connected to the slave, allowing it to see the Clock Pulses. If off, the slave doesn't see any pulsing on the clock line, so sits idle, and the master doesn't see anything different on the line.


The other options are an i2c buffer, bus expander, or switch, with an enable pin. Some of those tend to require an extra i2c address byte to allow communication to the other side.


schematic



No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...