The DS1307 has two power sources: the main VCC source and the backup battery. The latter will power the DS1307 when the main power goes down so the clock can keep ticking.
I am facing a problem with the RTC DS1307 when the main power suddenly goes down and then return back the time on the LCD just freezes. Sometimes when that happens (power off) the RTC keeps running (it seems that the DS is stuck when the main power off).
This is the exact circuit I used and the battery gives 3.0V:
The code I used is exactly in blog post: DS1307 Real Time Clock Working.
What could the problem be?