2
\$\begingroup\$

On a multimaster i2c bus, how to determine which device started the transfer?

update (from comments made below by the O.P.) :

I am trying to make sense of http://www.i2c-bus.org/serial-resistances-and-debugging/ where it says:

it is possible to recognize which I2C device is currently active by analyzing the low level on the I2C lines

What does that mean?

\$\endgroup\$
  • \$\begingroup\$ You mean, with one of the devices or with an external device? \$\endgroup\$ – Keelan May 17 '13 at 19:01
  • \$\begingroup\$ From observing the bus traffic with an analyzer. \$\endgroup\$ – sram May 20 '13 at 13:10
2
\$\begingroup\$

I2C spec itself doesn't have provisions for "from" address, AFAIK.

You would have program the masters to transmit their IDs in the payload part of the I2C packet.

\$\endgroup\$
  • \$\begingroup\$ That is a good idea from higher level. I am trying to make sense of i2c-bus.org/serial-resistances-and-debugging where it says "it is possible to recognize which I2C device is currently active by analyzing the low level on the I2C lines" What does that mean? \$\endgroup\$ – sram May 17 '13 at 19:08
  • \$\begingroup\$ The voltage on the data line will be lowest at the active transmitter. \$\endgroup\$ – Peter Bennett May 17 '13 at 19:33
  • \$\begingroup\$ @sram You should expand your post and describe what you're trying to accomplish. 1-sentence question will not get you very far. \$\endgroup\$ – Nick Alexeev May 17 '13 at 20:08
  • \$\begingroup\$ The difference in voltage levels as measured at different devices will be miniscule; far below what you could accurately measure with a scope. \$\endgroup\$ – alex.forencich Apr 11 '15 at 3:39
0
\$\begingroup\$

In some cases, one may be able to infer which device started a transfer based upon the relative voltages at the ends of the connection, or if different devices will send different sorts of data. Otherwise, the only thing any device knows who's the master of the bus at any given time is "maybe me" or "not me". Note that if two devices both try to perform the same transaction roughly simultaneously, it's possible for both devices to regard themselves as having been masters of the bus. This could in some cases cause problems. For example, if an I2C slave device has a counter which increments every time it's read, and if masters try to assign themselves addresses by reading that counter, it would be possible for two masters to issue simultaneous requests to read the counter, and for each to read the response and think that it's the only thing in the universe that read that value.

If nothing on the bus knows who the bus master is at any given moment, there's not apt to be a 100% reliably way for an outside observer to figure it out.

\$\endgroup\$
0
\$\begingroup\$

Different devices will have different output stages and so will drive the bus slightly differently. Since I2C is an open drain bus, the only thing that you can look at is the low level as the high level is determined by the pull-up resistors. If you can identify what specific voltage each master drives as a low level on the bus, then you can figure out which master is controlling the bus. You will need an oscilloscope to measure this and observe the bus traffic; a logic analyzer or protocol analyzer that only records the level as high or low is not sufficient. You might be able to put some low value resistors in series with the I2C pins on one or more of the masters. These resistors will form a voltage divider with the bus pull-up resistors and will change the low voltage as asserted by the devices. Putting different resistor values on different devices will make them easier to identify. Note that the resistors have to be as small as possible so as to not slow the bus down too much or shift the low level too much.

Another thing to look at is the precise period of the clock. Different masters will have different clock sources and baud rate generators and may produce slightly (or significantly) different baud rates. It may be possible to track which master is controlling the bus looking at the clock period with a fast oscilloscope or logic analyzer.

\$\endgroup\$
0
\$\begingroup\$

What the linked article is trying to say is that not every I2C device will "pull" the bus down the same as others, and goes on to exaggerate this by intentionally weakening one of the devices with a series resistor. Trace resistance and drive strength will determine just how low a logic low really is, as you can see from the picture on that page:

image showing SCL/SDA with two different SDA drivers

The author of the page has placed a 200 ohm resistor in series with the SDA line and is measuring the voltage at the slave. Since the master has been made weaker, it won't pull to ground but rather to a small positive voltage (which is still low enough to be seen as a logic 0 by the slave). Thus with a scope you can see that the device that is driving all the way down to zero is the slave (since it does not have an additional 200 ohms of resistance between its driver and ground), and the device that is pulling almost to ground is the master.

I used a similar technique when I was debugging the Nintendo 64 controller protocol. It's a one-wire bidirectional protocol and I wanted to know what each side was transmitting. I placed a 330 ohm resistor in the data line and measured across the resistor. Positive pulses were the master talking to the slave, and negative pulses were the slave talking to the master. You could do the same here, as long as your oscilloscope's ground lead was not tied back to earth ground (or if you used a differential probe).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.