PDA

View Full Version : Does I2CREAD/I2CWRITE check for bus status?



EToscano
- 15th October 2009, 20:10
Hello again, this is for the more versed in PBP, is there a way to check the bus status in I2C in order to avoid collisions? I can't find more docs about this issue.

Best regards

E.T.

Darrel Taylor
- 15th October 2009, 21:04
No, I2CREAD/WRITE are intended to be used as the only Master on the bus.

You could have another line between the masters with a pull-up resistor.
Whenever one of the chips is going to access the bus ... pull that line low to tell the other chip the bus is busy.

Check that line before accessing the bus, pull it low for a short period, then release it and check again. If it goes high, pull it low again and go ahead and access the bus. Just in case they both try to do it at the same time.

hth,

EToscano
- 15th October 2009, 23:53
No, I2CREAD/WRITE are intended to be used as the only Master on the bus.

You could have another line between the masters with a pull-up resistor.
Whenever one of the chips is going to access the bus ... pull that line low to tell the other chip the bus is busy.

Check that line before accessing the bus, pull it low for a short period, then release it and check again. If it goes high, pull it low again and go ahead and access the bus. Just in case they both try to do it at the same time.

hth,

Got it, I'll give it a try. Thanks a lot.

Darrel Taylor
- 16th October 2009, 04:39
Hope it works for you.

Just want to thwart one potential problem ...

NEVER take that line HIGH!
Only use the LOW and INPUT statements on that pin.

A small resistor (220 ohms) in between the two PICs can protect against the accidental possibility.

hth,

EToscano
- 16th October 2009, 16:43
Hope it works for you.

Just want to thwart one potential problem ...

NEVER take that line HIGH!
Only use the LOW and INPUT statements on that pin.

A small resistor (220 ohms) in between the two PICs can protect against the accidental possibility.

hth,


Just in time! thanks again.

E.T.