Go Down

Topic: How to prevent freeze due to missing I2C pull-ups? (Read 91 times) previous topic - next topic

MikD

Searching for Arduino and I2C solutions that freeze result in 1000's of pages. But I wonder if there is a way to detect the missing pull-up resistors? On Arduinos with a stand-alone USB chip this is less of a problem once pull-ups are in place. However, on the Zero loss of USB communication is problem. No doubt that double clicking the reset button, when doing a new upload, fixes the problem and being the fastest double clicker in a radius of 6 hours drive from where I live I manage. But for the untrained user loss of USB can result in despair or lots of hours lost.

So I thought isn't there a way to avoid the freeze by telling the user to connect the necessary H/W?

I have tried to set the pinMode to input and do a digitalRead before Wire.begin(). But unfortunately the result is HIGH no matter if pulled-up or not.

I have also tried to do:
Code: [Select]

pinMode(pinSDA, INPUT);
digitalWrite(pinSDA, HIGH);
pinMode(pinSCL, INPUT);
digitalWrite(pinSCL, HIGH);
Wire.begin();


What is interesting about the latter experiment is that the freeze doesn't seem to occur. But the MCU becomes very slow, but it will get past the critical point. Of course I2C doesn't work. But I don't really like this solution. I also tried to measure the progress of time using micros(). But the difference seems to be only 1 us. So this is not a reliable solution either I think.

So I am back to my original question. Isn't there a reliable way to detect and act upon?

My solution has a ~20 cm long I2C bus. So not a lot of capacity present.

TIA

Go Up