DS1307 rtc hang-up

I have tried everything and I can't understand this. I have a ds1307 rtc, the right crystal and a battery. Everything apparently works fine.

When I try the battery, to see if everything works, I detach the VCC cable from the pin8 on the ds1307 and when I attach it again I see that the battery works, because the time is exact.

Looks like ok BUT.. When I detach the +5 cable from the arduino (meaning that breaks the connection with pin 8 VCC, 5 SDA,6 SCL) and I attach it again, most of the times (but not every time) the RTC hangs and show always the time when i gave again the +5. (Looks like hanging in the exact moment that I put the +5)

I am working on this from many hours, without understanding why it stop working...

Thank you for help!

Is the battery good?

Do you have a schematic?

This scenario has worked quite well for me, except for the time the coin cell went dead. (note to self: don't expect much life from a battery that has been in a drawer for 14 years).

-j

Hi! Basically my scheme looks like this http://img89.imageshack.us/img89/6505/ds13070sm4.gif with the pullup resistors.

During the last hour, things started to work. Looks like... I have the system in test because is running by one hour, and I am continuosly detaching the current and keep working.

I have added an electrolitic capacitor, 10uF 25v beetween the vcc and gnd of the ds1307 and now looks like working. Don't know exactly WHY, by the way. I tested just because I was without any other idea, and looks like a solution. (Well, if this keep working)

Can't understand why...

I have added an electrolitic capacitor, 10uF 25v beetween the vcc and gnd of the ds1307

It isn't on the DS1307 datasheet "typical application circuit", but nearly every digital device recommends a 0.1uF cap between Vcc and ground. Digital devices make noise, the caps help reduce it.

Since the cap fixed it, something in your circuit was probably generating noise that you are now filtering out.

-j

Thank you, I will try also a smaller cap, to see what happens! Federico

Hi federico, have you any news about this problem? I have the same your problem, when disconnecte time halts :-(

I know that when using the ds1307, I made the stupid mistake forgetting to disconnect the RTC and reprogram the arduino w/ code that didn't set the time again after I initially set it (and also forgetting that opening up the serial monitor from w/in the IDE reset the arduino).

I'd try disconnecting the RTC from the I2C pins first, and then 5V, if possible, but that's just a random idea. On the same note, verify that your ground connections all go to a common ground.

Also, exactly what crystal are you using? Some minor error in choice of crystal might be stopping the oscillator.

Finally, how far is the ds1307 from the arduino (ie, is it on a protoshield, or on a breadboard 10 feet away connected by a massive lenght of wire). I've never had any problem w/ noise on VCC when using this chip, so I've never had to use a cap. But I'm also using relatively short jumpers between the RTC and the arduino.