Question about I2C bus

Dear all,

If there are 2 or more I2C device driver access the same I2C bus simultaneously,
is it possible to corrupt the data that transferred from driver? or is it possible to cause any other issues?

If the answer is yes, please give me some suggestions to avoid or solve this problem.

Thanks in advanced.

I2C has an arbitration mechanism which will keep two well behaved hosts from stepping on each other.

For a single host the same arbitration mechanism would apply - as long as the controller driver is well behaved it should not end up mixing the data of transfers on the bus.

Now that said - it is possible for two clients to see their transfers interleaved if they let go of the bus. Write command A, write Command B, read data from A, read data from B. The controller driver should take care of this.

Two drivers sending commands to the controller driver simultaneously should be fine. Two drivers cannot “access the same I2C bus simultaneously”

-p

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Tuesday, July 22, 2014 5:47 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Question about I2C bus

Dear all,

If there are 2 or more I2C device driver access the same I2C bus simultaneously, is it possible to corrupt the data that transferred from driver? or is it possible to cause any other issues?

If the answer is yes, please give me some suggestions to avoid or solve this problem.

Thanks in advanced.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Peter Wieland wrote:

I2C has an arbitration mechanism which will keep two well behaved hosts from stepping on each other.

In my experience, however, many I2C devices are not “well behaved”.
That’s especially true when I2C is handled in a micro’s firmware by
bit-banging; almost no one handles the arbitration correctly.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Agreed. The question was “two or more i2c drivers” access the bus simultaneously and I interpreted that to mean two drivers on the same machine going to the same controller.

If those two I2C drivers are talking to different controllers attached to the same bus now you’re in multi-master land which adds the layer of complexity that you have to depend on the two masters to behave nicely.

-p

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Tuesday, July 22, 2014 9:22 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Question about I2C bus

Peter Wieland wrote:

I2C has an arbitration mechanism which will keep two well behaved hosts from stepping on each other.

In my experience, however, many I2C devices are not “well behaved”.
That’s especially true when I2C is handled in a micro’s firmware by bit-banging; almost no one handles the arbitration correctly.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

According to the I2C spec, the arbitration mechanism is implemented for multi-master by a kind of theory called wire-AND.

Therefor, my understating of I2C arbitration mechanism is that just support multi-host system,
no idea why the single controller system is also able to have capability of arbitration.
Is it implemented by controller driver?

OP: I’m not completely clear on what you’re asking.

I2C is like USB. Drivers for devices on the bus send packets of commands to the bus controller driver, and the bus controller driver handles all physical access to the bus.

So… Having two devices on the same bus shouldn’t be a problem, as there should only be one driver --the controller driver – that’s talking to the controller.

Peter
OSR
@OSRDrivers

xxxxx@hotmail.com wrote:

According to the I2C spec, the arbitration mechanism is implemented for multi-master by a kind of theory called wire-AND.

True. In I2C, no one ever drives a “1” bit. Every signal floats high
(1) unless someone specifically drives it low (0). So, let’s say you
are driving a 0 bit. When you are done, you release the line. If the
signal stays 0, then you know someone else must be driving it to 0.

Therefor, my understating of I2C arbitration mechanism is that just support multi-host system,
no idea why the single controller system is also able to have capability of arbitration.
Is it implemented by controller driver?

I think you are mixing two different meanings of the word
“arbitration”. The arbitration mechanism in the I2C spec is strictly a
hardware-level signalling scheme. It allows one master chip to tell
whether another master chip is currently driving.

In a single controller system, the spec still has the concept of
arbitration, but it would never be used. Since there is only one
master, nothing will happen on the bus until the master starts it.

None of this has anything to do with drivers and software. This is all
electronics. If all of your I2C controllers have drivers, and those
drivers coordinate between themselves, then you wouldn’t need the I2C
arbitration.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

On 28-Jul-2014 10:19, xxxxx@hotmail.com wrote:

According to the I2C spec, the arbitration mechanism is implemented for multi-master by a kind of theory called wire-AND.

Therefor, my understating of I2C arbitration mechanism is that just support multi-host system,
no idea why the single controller system is also able to have capability of arbitration.
Is it implemented by controller driver?

The i2c host controllers on many (important) platforms support SMBus.
SMBus is subset of I2C electrically and it specifies
arbitration for multi-master and for dynamic assignment of slave
addresses. Oftentimes, when they say i2c, actually they mean SMBus.
You are welcome to get the spec at smbus.org, it clarifies many details.
– pa

If you’re asking why it’s safe for multiple clients on a single system to all send I2C requests at the same time to the same controller, it’s because the device driver serializes them.

For each of those requests the driver causes the controller to run through the sequence needed to wake up a particular I2C device and have it start listening for traffic. That sequence includes an arbitration step, which does nothing on a single master system.

-p

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Monday, July 28, 2014 12:19 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Question about I2C bus

According to the I2C spec, the arbitration mechanism is implemented for multi-master by a kind of theory called wire-AND.

Therefor, my understating of I2C arbitration mechanism is that just support multi-host system, no idea why the single controller system is also able to have capability of arbitration.
Is it implemented by controller driver?


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer