I have made a simple board using AT89c52 and DS1307. I works fine normally, but during sudden power failure and restore of power, sometimes the time stored in RTC is corupted. I tried by making seperate power supply to RTC and early RESET to micro controller during power fail, still the problem is not solved. Can you help me ?
It's been a year or two since I first played with a 1307 and I recall having problems similar to what you're saying. I added a coin-cell backup battery to keep the time alive when the power failed. IIRC, it has to do with having power interrupted when you are "talking" to the 1307. Try enabling "brown out detect" if you have that option so that the processor won't try doing I/O without enough voltage available.
I have had the same/similar problem and have given up....The RTC is now strapped to VCC and we don't rely on it's memory to re-instate the true time.Then we just ran the chip as a time counter. We still had problems.. Now we've given up altogether and use an RTC derived from the CPU XTAL The main problem seemed to be that the RTC chip would lock out the CPU on powerup, maybe getting the SDA SDC in a twist. Being backed up by a coin cell meant we had to remove the chip to 'unlock it'. Bloody nightmare. :( There's no brownout on a 52 and I doubt that will help.......
We use the DS1307 in a couple products (thousands of units in the field) and I have never run into any problems other than being interrupted by a power fail in the middle of a write and we only write when a human needs to set the time. I did make one small change over how most people might run the IC, and I don't know if this might be why I have not had any problems, but I use a small coin cell hooked to the Vbat input and I use an output pin from the MCU to supply Vcc to the 1307. On power up the rest of the system is initialized and before I use the clock for the first time I pull that IO pin high. That lets me do a couple of different things. It let's me go into deep sleep where the clock is powered down and the MCU has built in brown out detection, so when the power fails and the reset gets pulled low, the IO pin goes back to high impedance mode cleanly killing the power to the DS1307 and it will not get it back until the system completely reinitialized. Anyway, I may try strapping one of them straight to Vcc to see if the date and time get buggered up, hmmmmmm.
Excellent idea..... I have just gone back and looked at our design. I was mistaken, we use the DS1377( not 1307). This is driven by a DS1218 Vcc/Batt switching chip,that also controls our /WE on the 32K CMOS ram. We get no problems with RAM at all. Al my previous comments refer to this setup.