7
\$\begingroup\$

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:

Schematics

The code I used is exactly in blog post: DS1307 Real Time Clock Working.

What could the problem be?

\$\endgroup\$
  • 1
    \$\begingroup\$ Are you 100% certain that it's the DS1307 that's glitching? Have you connected an independent I2C interface to the SCL and SDA lines and attempted to query the IC? Your question also contradicts itself: at one point you say the part keeps timing when the power goes off, then in brackets you say "stuck when the main power (is) off" - is it or is it not stuck? \$\endgroup\$ – Adam Lawrence Dec 13 '12 at 11:58
  • \$\begingroup\$ @Madmanguruman: what else could be? I tried an other ATmega and the problem still happening ,i connect it to arduino uno and with serial monitor -RTClib example- it sends correct data(time) to computer , I plug off the power, sometimes it keep timing and sometimes it stuck you can I say it's random!! \$\endgroup\$ – alone Dec 13 '12 at 21:55
3
\$\begingroup\$

Schematic is good. Run this checklist:

  • Check your power supply for clean wave, specially on connect and disconnect times. If it pikes for more than 1V add 4.7uF capacitor. If it do not fix the problem, change power supply and renew DS1307.

  • Check 3V battery current capability, no voltage only, DS1307 need 200uA min.

  • Check for 3V bat having unwanted path discharging it. Specially if you are using protoboard.

  • Check I2C commands/software.

\$\endgroup\$
  • \$\begingroup\$ thank you for your help i but a 4.7uF parallel with the source and it resolve the problem thank you for your help \$\endgroup\$ – alone Mar 6 '13 at 18:22
2
\$\begingroup\$

Usually this kind of problem arises due to:

  1. Power Supply not dealing transients at Power outage and when it is restored.
  2. Bad Cell
  3. Sometime it due to the Software bug...
\$\endgroup\$
  • \$\begingroup\$ thank you ... but i checked my power supply and the battery and there is no problem.... i resolved it by a c4.7uf parallel with the main 5v regulator \$\endgroup\$ – alone Mar 6 '13 at 18:19
1
\$\begingroup\$

Check to make sure you are resetting the I2C bus properly on startup. If you aren't you'll see that when your program is locked up the data line will be low all the time. You can resolve this issue by sending clock pulses from the master until all devices have released the data line.

\$\endgroup\$
  • \$\begingroup\$ thank you .... but the I2C bus reset properly ..i found the solution to add a 4.7uF parallel with source \$\endgroup\$ – alone Mar 6 '13 at 18:21
1
\$\begingroup\$

Have you made sure to do as recommended in the data sheet:

CLOCK AND CALENDAR


Bit 7 of register 0 is the clock halt (CH) bit. When this bit is set to a 1, the oscillator is disabled. When cleared to a 0, the oscillator is enabled. Please note that the initial power-on state of all registers is not defined. Therefore, it is important to enable the oscillator (CH bit = 0) during initial configuration.


In other words, if you forgot in your software initialization to reset the CH bit, the oscillator would not work (and the bit value is random at power up)

\$\endgroup\$
  • 1
    \$\begingroup\$ thank you for your answer, i made the "CH" bit initialization and i have found a good solution by adding 4.7uF parallel with the 5v regulator(at the main source) and it works good \$\endgroup\$ – alone Mar 6 '13 at 18:13
  • \$\begingroup\$ Glad you have solved it. \$\endgroup\$ – Drazen Cika Mar 10 '13 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.