# I2C with DS1307 hang after end of transmission

I've got a home brewed RTC with DS1307. I've put two pullup resistors on SDA and SCL lines, connected them to the Arduino 5 and 6 pin respectively. I've also provided a backup battery since I read sometimes the RTC can hang if there is not a proper backup voltage. The arduino program hangs on the instruction:

int err = Wire.endTransmission();


I guess there is no reply from the device so SW wait indefinitely. Strangely if I remove the I2C conenctions, endOfTrasmission returns a NACK error code ( I say strangely because I better expect an hang without any device connected ). I have no idea on what to test, I suspect the DS1307 being damaged by some adventurous test in swapping A5-A6 data but I have no idea of how to make this diagnosis.

• What sense would it make to hang the write if the slave doesn't ACK? It's not like it might come back later; it's missed its chance. More likely, the DS1307 is holding down the SCL line. The master would interpret this as a "clock-stretch" and could wait indefinitely for it to be released. As you say, you may have damaged the chip or you have a short on the package. – DoxyLover Apr 9 '13 at 21:57
• Please share a more complete block of code, simplified to the bare-minimum functionality desired. It is conceivable that the Wire.endTransmission() line is not where it is hanging, but some subsequent line. – Anindo Ghosh Apr 10 '13 at 4:03
• @AnindoGhosh I did a lot of tracing and I can confirm it hang on endTrasmission() ie when it try to actually send the data. – Felice Pollano Apr 10 '13 at 7:19
• @FelicePollano You aren't making it easy for people to try figuring out the issue, by not sharing a minimal code block that others can at least try to use on their own systems. – Anindo Ghosh Apr 10 '13 at 7:21
• @DoxyLover you are correct: there was a short between SCW and SCL kkeping, as you said, low the clock signal. Now it works like a charm. If you want send a reply I will vote and accept, thank you! – Felice Pollano Apr 10 '13 at 20:27