# I2C only works when probed or loaded with 1Mohm

I am trying to troubleshoot communications between an msp430fr5847 (master) and a slave sensor with unknown I2C chip (part of an industrial sensor)

I am having issues with a new batch of sensors where my data is being returned with all zeros, however when trying to troubleshoot with my Saleae logic pro (2Mohm, 10pf), or my oscilloscope (10Mohm, 50pf) the system works perfectly when probing the SDA pin.

Troubleshooting further the circuit works correctly if I add a 1Mohm resistor between SDA and ground, but does not work if only adding a 10pf or 100pf capacitor.

I am using 4.7k pull up resistors to my 3.3v rail.

What could be causing this issue, and what can be done to troubleshoot without unintentionally fixing the problem.

EDIT: 19/07/2017 Here is a quick scope trace of my signals.

Something else I forgot to mention is that only probing SDA causes the board to work, probing SCL or my interrupt line does not get it to work properly.

EDIT: 21/07/2017

The plot thickens, it appears that connecting a different oscilloscope does not get the circuit to work correctly, and it can be seen that the only difference is that an ACK is not being transmitted.

In the above picture, the blue and green traces are the SCL and SDA when the circuit is not operating correctly. The yellow and pink traces are from when I also connect my Saleae logic to the SDA Pin and ground but without plugging in USB (trying to avoid ground loops).

To add a bit more background on the sensor it is an industrial pressure sensor we buy in from the manufacturer. We have previously designed and tested these PCBs with our first batch of sensors. We have recently received a new batch and are now encountering these issues. I have done a bit of investigation and I strongly suspect (after googling unique looking sentences from the datasheet) that internally the sensor uses a ZSC31014 or similar, PDF datasheet HERE

EDIT: 26/07/2017

So hopefully the last installment in solving this issue, as per SamGibson's detailed answer I have implemented the fix of setting the high bit of the address to mask the glitching at the end of the start bit.

This has worked mostly with data coming through as expected, however now it appears that in in the first read command after a write (if that is the correct term for a group of i2c bits), the slave attempts to ACK one bit early (in the position of the write bit). I can tell that it is the slave pulling the line down through adding a small (47 ohm) resistor in series with the SDA Line.

I would usually start this as a new question but when I attach the same scope that had no effect in the above troubleshooting, this issue seems to go away, this really does seem to be a borderline issue as even if I attach the scope probe, without connecting it to the scope the issue is solved so I am assuming it is a capacitance issue.

Plot of issue with no scope attached

Plot of issue with scope probe attached, but not attached to scope, noting the slightly higher voltage when the slave pulls down the write bit instead of the ACK bit.

• Do you have any scope traces – Kevin White Jul 19 '17 at 14:21
• Have you inadvertently inverted your clock signal? – Andy aka Jul 19 '17 at 14:51
• Confirm that the I2C bus has, and is using, a common ground wire (MSP to the I2C sensor). 3 wires required: SDA, SCL, and GND, with SDA & SCL pulled up to Vcc (possible 4th wire) through pull-up resistors. – Chris Knudsen Jul 19 '17 at 16:46
• @Hugoagogo - Yikes! Both SDA & SCL abnormal, in different ways. I assume that trace is with the new failing sensors? If so, can you supply a trace with the old working sensors? Perhaps the difference may not be so big i.e. you had a problem before, but it was just working. More background info might reveal useful data e.g. How do you know these are "new" I2C chips, considering the chip is "unknown"? I'm guessing some reverse-engineering was done to allow the MSP430 (which you control?) to be used with a sensor (that you don't control?). How different is that from the "original" config? – SamGibson Jul 19 '17 at 22:08
• Well, I agree with SamGibson. I wouldn't be so quick in saying that the spikes are measurement errors. I think you should try to research it a bit further and try to eliminate them, if they come from your measurement setup or find the reason why they are there. After all, they seem to be aligned with falling edges of SCL. I would also try to hook up the sensor directly on the PCB. That could help you rule out that the problems are caused by the cable or the distance of the sensor from the main board. – nickagian Jul 20 '17 at 7:05

I think I've found the answer. It turns out this is a known problem, but I only found that after I'd decided where the problem was, and searched for that!

Here is the process I went through, so you can follow it (and, if necessary, you can then adapt your investigation if you see results which differ from my assumptions). The bottom line is that there appears to be an incompatibility between (at least some) MSP430 I²C behaviour, and the required I²C behaviour by the device you suspect to be the I²C Slave, the IDT ZSC31014. Having the datasheet for that device is critical to understanding this, so thanks for finding it.

The good news is that there are (at least) 2 workarounds for this problem, which I'll explain at the end.

The plot thickens, it appears that connecting a different oscilloscope does not get the circuit to work correctly, and it can be seen that the only difference is that an ACK is not being transmitted.

The new traces are helpful, thanks, although I interpret them a bit differently.

(The SCL signal undershoot, which concerned me on the initial trace, is still there on the latest trace. It's interesting that the undershoot on SCL seems greater than the undershoot on SDA, especially considering the different vertical scales between SCL and SDA signals on the latest trace. I would still suggest to investigate that SCL undershoot eventually, but I don't believe it is related to the main problem.)

There are those two "glitches" on SDA:

• A glitch just before or just after the ACK pulse is not uncommon, when an I²C Master releases control of SDA to allow a Slave to perform the ACK and then the Master might re-drive SDA again. Therefore I'm ignoring that one.

• It is the early SDA glitch, before the first SCL pulse, which is more unusual. From the amplitude of that early SDA glitch (see later) and the fact it occurs only before that first SCL pulse (labelled 0), but does not occur before later SCL pulses where we would be able to see a glitch on SDA (like SCL pulses labelled 4, 5, 6 or 7), we know it is not a measurement artefact, nor coupling from SCL (for example).

(For later reference, the early SDA glitch looks like at least 2V in the latest trace, so with Vdd at 3.6V from earlier comments, that makes the SDA glitch amplitude at least (2/3.6) = 0.55 x Vdd. Compare that with the relevant I2C logic level thresholds discussed later.)

Ignoring the ACK difference, I believe I see another difference between the two sets of traces in that second screenshot. The amplitude of that early SDA glitch seems slightly different, comparing the top SDA trace labelled C1 (yellow-ish?) and the 2nd SDA trace labelled M3 (blue). I now believe that differences in the amplitude of that early SDA glitch, is what can cause your issue to appear or disappear, as I explain below.

Even more resolution specifically on the glitch would help (that is one of the problem in trying to work on problems "remotely" - I can't operate the 'scope myself!). I'll assume that when you zoom in, it looks like the start of a normal I²C logic "1" (i.e. an RC curve on the rising edge, especially if you temporarily make the pull-ups weaker e.g. 10k) except it doesn't reach the full positive voltage before it is driven to a logic "0" again. That is what is shown on another webpage linked later. If you see different shape to your glitch, then my later analysis might not apply.

The I²C Master is in control of the bus at the point of that glitch, between the I²C Start and the first SCL clock pulse (which you've labelled "0" although it's the MSbit). That made me suspicious of the MSP430 behaviour, although with SCL low at that point, an SDA glitch shouldn't affect I²C-compliant devices, as they will be waiting for SCL to go high before they next read the state of SDA.

So, is that I²C Slave really I²C-compliant? It turns out, the ZSC31014 is "fussy" and less tolerant than some other I²C devices, at exactly the time when I believe the MSP430 is producing that glitch!

The ZSC31014 datasheet lists 3 areas where they admit the device's I²C behaviour is "different". You might also be affected by the first two in this list at other times (that isn't part of this analysis), but it is the third point which I've marked below in red, which is related to that early SDA glitch:

The amplitude of that early SDA glitch is critical. If that glitch does not rise enough to be recognised by the ZSC31014 as a logic "1" before it falls again, then you are OK - the device has to see a falling edge on SDA to break that "rule" and it can only be a falling edge if it has already been recognised as a logic "1".

Anything which affects the amplitude of that SDA glitch, like the additional load of a 'scope or logic analyser on the SDA signal, might be enough to stop the glitch being recognised by the ZSC31014 as reaching a logic "1" and therefore no "falling SDA edge", that third point in the list, can occur (on a good day, depending on voltages, temperatures etc.). However, as you have found, the variation between different oscilloscopes is enough to mean that some of them add enough load to stop the problem, and others don't. This setup must be very marginal!

This confirms my worry that your earlier "working" batches of sensors, might be "only just" working, since the MSP430 MCUs on those "working" setups will likely also be producing SDA glitches. My theory about a possible difference between batches of sensors, which could explain the different behaviour you have reported ("working" batch vs. "non-working" batch) is explained next.

Interestingly, the ZSC31014 is different from standard I²C in another area which is not mentioned on that list from the manufacturer, and this could explain why you seem to see a difference between batches of sensors.

Standard I²C logic thresholds are (simplified) - below 0.3 x Vdd for logic "0", and above 0.7 x Vdd for logic "1" as shown in the I²C specification:

However the ZSC31014 has different thresholds, 0.2 x Vdd and 0.8 x Vdd, meaning that its "undefined region" between those thresholds is larger than typical I²C devices:

That larger "undefined region" increases the chance of the glitch entering the undefined voltage level area, where it might be recognised as a logic "1" (remember, anything above 0.2 x Vdd could be recognised by the ZSC31014 as a logic "1", since in the undefined region, anything is allowed - it is only above 0.8 x Vdd when it must be recognised as a logic "1"). And, as explained before, if the glitch is recognised by the ZSC31014 as having reached a logic "1", then when it falls again to a logic "0", you have broken that "rule" marked in red for the I²C behaviour required by the ZSC31014.

Since the recognition of logic levels in that "undefined" voltage region is not specified, the sensor manufacturer is not breaking the specification if they make one batch that recognises logic "1" only when it reaches 0.7 x Vdd, but make another batch which recognises a logic "1" as low as 0.4 x Vdd, for example. That hypothetical second batch would be more likely to see the SDA glitch as a falling SDA edge, in violation of that third point in their list, yet not be breaking their specification.

(Many of the problems I've worked on, over the years, have been like this: There are two devices, neither of which is individually breaking a specification which has loopholes - but one is fussy and less tolerant, on a point where the other one needs connected devices to be more tolerant because of its obscure behaviour! Each of those two devices is fine interfacing with the majority of other devices, but are unreliable (or completely fail) when connected to each other.)

So what can you do? I thought of two options:

• Don't use an MSP430 - use another MCU which doesn't create that early SDA glitch. However I expect you have invested lots of time in the software and would not want to port the code to another MCU, if that could be avoided.

• "Bit-bang" the I²C protocol on the MSP430, instead of using its built-in I²C hardware module. That way, you are in total control of the I²C signals and can prevent that glitch from occurring. However, it would obviously be some work to create your own I²C routines, debug them, and the resulting code may be larger than when using the MSP430 I²C hardware module, which itself could be a problem if you are short of Flash space.

Then I went searching for MSP430 I²C issues, and I found that this combination of MSP430 + ZSC31014 is a known problem, due to that early SDA glitch from the MSP430! See this thread on the TI E2E MSP430 forum:

TI E2E forum: MSP430 I2C glitch pulses causing trouble for I2C peripheral chip

The workaround mentioned there, is to change the ZSC31014 I²C address so that SDA is high at the time when the positive glitch could occur, and since SDA is made high then anyway, there is no actual glitch on SDA:

Our workaround is to configure the ZSC chip to have an address with its bit 6 set (e.g. we’re now using 0x42) - this turns the glitch pulse into a nice clean "high" bit for the address bit 6 duration, which gets rid of the problematic falling edge.

The same workaround is effectively the reverse of the suggestion in the ZSC31014 datasheet, in the red box which I marked. They say an SDA glitch must be prevented if the first bit (which is the MSbit) of the ZSC31014 I²C address is 0 - so don't make the MSbit of the I²C address a "0", make it a "1" instead i.e. set bit 6 in the 7-bit I²C address!

Since that TI E2E forum thread and the ZSC31014 datasheet are both focussing on the I²C address, then perhaps either the SDA glitch doesn't occur, or is not a problem if it does occur, during the sending of other data on the bus. You will need to investigate that.

Therefore, ignoring the first workaround of using a different MCU, the two (more practical) workarounds are either:

• Bit-bang the MSP430 I²C bus by writing your own code, so that you don't create that glitch on SDA, or
• Change the ZSC31014 I²C address so that bit 6 of its 7-bit address is set, meaning that SDA is already high when the glitch would otherwise occur, so no actual glitch occurs on SDA when the ZSC31014 is addressed (assuming that an SDA glitch either doesn't occur after other I²C Start events during data transfer, or if one does occur, that the ZSC31014 doesn't get "upset").

Hope that helps!

• This is an awesome and very helpful answer, before I mark as accepted is there any way I can give you some more rep for sticking with it through the troubleshooting. I will also update my question with my workaround when I get it going. – Hugoagogo Jul 22 '17 at 7:11
• @Hugo - That's a very kind thought :-) I believe it can be done by offering a bounty where the bounty reason would be "Reward Existing Answer". I'm not an expert in the process, so I can't say much more than that. Of course I'd be happy to have extra rep (it has taken a few hours to do the analysis and write-up ;-) ) but if you don't want to use a bounty, or can't figure out the process, then no worries, it's all positive karma anyway :-) Hope my answer works! – SamGibson Jul 22 '17 at 7:19
• @Hugo - I don't know if you get notified of updates to answers, but just FYI, I've added a paragraph about SCL and its undershoot (still a puzzle, but I doubt it's related to the main problem) and I've guesstimated the amplitude of the "early SDA glitch" in the latest scope trace as being at least 0.55 x Vdd, which is well into the "undefined" voltage region, where different sensors (or different batches of sensors ;-) ) could treat that as a logic "1" or not, without breaking their specification. I'll be offline for a while soon, so again, good luck! – SamGibson Jul 22 '17 at 8:11
• Thankyou again for the assistance I will have a go with the bounty on Monday when I am in. (For the record I don't get notified of updates to answers) – Hugoagogo Jul 22 '17 at 8:26
• would I be able to get you to weigh in on one last update to the question. – Hugoagogo Jul 26 '17 at 21:26