Electronic – I2C – Cannot read temperature from TC74 with PIC16F887

i2cnoisepictemperature

The question was:

I want to read temperature from TC74 using I2C module of PIC16F887, however, in Proteus
simulation, I see noises in I2C Debugger Tool's output.

It told me that I had "Spurious SCL transition". Any other info about the question such as schematics, code and screenshot can be found in the older revisions.

The problem is fixed after adding a 4us delay after a restart condition as it is stated in the datasheet as:

START Condition Hold Time – Min: 4us

START Condition Setup Time(for repeated START Condition) – Min: 4us

STOP Condition Setup Time – Min: 4us

That means that we should always read the datasheet thoroughly first.
I am guessing that the reason people in the internet don't have any error when they don't obey those wait times is that their clock speed is low and they don't need to put a delay in the uC.

Working code and any other information of this post can be found in the older revisions of it. To see the final version of question before this shrinking, simply go to this page.

Best Answer

I don't know what you mean by "Proteus simulation". In any case, there are some obvious problems in the schematic. First, it's clearly missing a bunch of connections, so we can't tell what is really hooked up. You are getting pins wiggling, so there must be power, that is not shown. That leaves the question of what else is not shown. And no, don't say it's all hooked up right and it doesn't matter. On closer inspection, the PIC doesn't even have power and ground pins at all in the schematic. Fix all these obvious things before proceeding.

Why the 10 kΩ pullups? Those can be OK for IIC, but will limit the bus speed. What is the IIC clock rate?

What voltage is Vcc? How is the PIC being clocked? If this is a simulation, what does the real hardware do? What is the "I2C" block in the top right corner of the schematic? If you're having a problem between a PIC and another device, remove everything else from the bus during debugging.

I realize this probably should have been a comment, but there was too much to ask to fit into a comment.