Electronic – Circuit only works when o’scope probe is connected

i2cpcbprobe

I am working on a circuit with a PIC mcu and an LCD display on a breadboard. The PIC communicates with the display via I2C. For some reason I can only get the communication to work properly when my o'scope probe is connected to the SDA line of the I2C interface. I know the communicate is working because the display shows my text. If I remove the probe and then restart the firmware the display stays blank. Any ideas what is happening here? I am using 4.7k pull-up resistors on both the data and clock lines of the I2C as recommended by the PIC manual. I also tried swapping the resistors out with 1k's and 10k's but that didn't seem to help. Also, it doesn't matter if the ground clip on my probe is connected to the PCB ground or not (so I don't think it's a grounding issue). Any ideas what is going on here? I know I should really get a real PCB made but I wanted to prove the design was good on the breadboard first.

Best Answer

You didn't say which PIC you are using, but there have been at least two confirmed bugs in the IIC mode of some of the MSSPs. One of them had something to do with sampling the ACK bit on the wrong edge of the clock. The bugs I know about were quite a while ago, so they have probably been fixed in newer PICs. Still, I tend to use all firmware implementation of IIC in master mode. You need the hardware to implement a slave, but in master mode you own the clock so it's easy.

The scope probe is adding a little capacitance to the SDA line, which slows down and delays the edges slightly. Something is probably not right in that there is a race condition in there somewhere. The slower or delayed edge of SDA is apparently making it work. Try putting a 22-47pF cap on the line and see if that appears to make it always work. I wouldn't want to ship it that way without knowning the cause and understanding that's a reliable fix though.

Another possibility is noise getting onto the line from other parts of the system. In that case the cap to ground is making the line a little lower impedance, which attenuates the noise a bit. If it's noise, then adding a cap to SCL will be fine. If there is a race condition somewhere, adding a cap to SCL will probably make it worse.

I've seen too many flaky things with IIC over the years so that now I use a firmware-only implementation whenever possible. In firmware I can guarantee that there are never two things happening on any one edge.