Electronic – arduino – I2C with DS1307 hang after end of transmission

arduinoi2crtc

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.

Best Answer

[Reposting my comment as an answer]

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.