As part as a hobby project I built a relatively simple BCD binary LED clock using a PIC micro controller and a DS1307 RTC. Upon battery power loss the DS1307 resets back to 01/01/00 00:00:00 which makes sense. However, since the user is only able to see hours, minutes and seconds on my clock it makes no sense to set the date.

My question is, what is the relevance of setting the date in a DS1307 in relation to timekeeping. As far as i know the only relationship between time and date is a leap second correction every few years which i doubt the DS1307 implements.

Is it okay to let the date remain 01/01/00? I would assume it wouldn't make the time drift a lot but maybe i am missing something.

Either way, it's just a hobby clock, accuracy isn't mission critical, I'm merely asking out of curiosity.

Thanks in advance!

  • 1
    \$\begingroup\$ That leap second correction over years is of course not implemented, because the RTC has a very high deviation If yours has an error of only 1sec/day it is excellent. \$\endgroup\$ – Marko Buršič Feb 15 '16 at 21:31
  • \$\begingroup\$ @MarkoBuršič showed you an important point. You can keep the date as is. Leap seconds occurs unpredictable (see Leap second wiki). DS1307 supports only leap years as you can read in the manual. If you want to play with your clock theoretical accuracy I found an interesting page related your RTC page. Real accuracy depends not only on the crystal but also on PCB layout. \$\endgroup\$ – kaliczp Feb 15 '16 at 21:53

You may very well operate the RTC chip by leaving the "date" field at its initial default value. You will find however, as you enable the RTC to count the "time" field that once each 24 hours the "date" field will accumulate another day.

Setting the "date" field or not will not be having any impact on the RTC's accuracy or in its power consumption in any realistically measurable way.

I have not worked with any RTC's with an "daylight savings time feature" (DST) but if there was an RTC with such feature and it was enabled you would see that interact with your "time" field. In that case you would probably want to have your time piece comprehend the date. Like I said though it is unlikely to find an RTC chip with DST feature as such feature is different in many parts of the world and is subject to change in any particular area at the whim of governmental types.

| improve this answer | |
  • \$\begingroup\$ I've seen two kinds of DST support on RTC hardware--some devices have a bit whose suggested use is to keep track of whether the clock represents daylight or standard time. At least one device has a function to nudge the clock ahead or back exactly an hour (without disturbing the seconds count), but with the fun little caveat that a request to set the clock back an hour which is issued between midnight and 1:00am will silently fail to do anything. \$\endgroup\$ – supercat Feb 15 '16 at 21:07
  • \$\begingroup\$ Thank you for the answer. What you describe is what I currently already have implemented so thank you for the clarification. I will have a look at some RTC's that do not keep track of date (or possibly use a PIC built-in RTC). \$\endgroup\$ – broodrooster Feb 15 '16 at 22:22
  • \$\begingroup\$ If you look for an MCU that has a built in RTC be prepared for some extra work, higher battery consumption and possibly some disappointment. Almost all the MCUs that I have looked at that support RTC do not have a separate battery that is auto switched on chip. So if you want to support on-chip RTC you are faced with designing your board with a more complex power delivery system that can switch between battery and Vdd. I am currently working with the PIC32MZ part family and if you want to keep the RTC working while the system is off the MCU needs to be put into a sleep mode whilst (continued) \$\endgroup\$ – Michael Karas Feb 16 '16 at 0:42
  • \$\begingroup\$ (continued from above) running off battery. The power consumption is way more than what you can achieve with an standalone RTC chip sitting on an I2C bus. Select the correct chip and it can support the battery switchover right on chip, last a long time on a small coin battery and have simple interface. \$\endgroup\$ – Michael Karas Feb 16 '16 at 0:45
  • \$\begingroup\$ (Continued) If you have an MCU that has onboard RTC you could still choose to use it at run time for faster access to the time values and just load it up at startup from the external RTC chip. I have even done something similar where I use a simple software RTC driven off a timer interrupt and just seed it with the starting time/date value from the external RTC. For some real time embedded systems taking the 6 or 7 msec to read an I2C RTC chip imposes a time delay that is not attractive. \$\endgroup\$ – Michael Karas Feb 16 '16 at 0:51

There is no relevance if you don't need it.

There are a few types of RTC available.

  1. Simple counter. It counts seconds since last set/reset.
  2. Clock. Counts time in human readable format, hh:mm:ss
  3. Calendar. Time and Date. The DS1307 is this.
  4. Alarm. It will interrupt on a specific date or time as set.
  5. Logger. Logs time of an event or interrupt.

Typically each one includes all of the ones above it. These are just extra features that you can use If you want to. Otherwise ignore them, unless the datasheet states they must be set to a specific valid value.

You can just ignore the calendar feature of the DS1307.

Frankly if you want a real hobbyist project, ditch the DS1307, and implement your own clock in software, with or without a 32 khz crystal.

| improve this answer | |
  • \$\begingroup\$ I realize it's overkill to use a DS1307, the PIC i'm using even has a built in RTC. However, the purpose of the project was to familiarize myself with protocols like I2C and how a typical I2C device's register system works. I did learn a lot so that goal was reached. Thank you for the clarification either way \$\endgroup\$ – broodrooster Feb 15 '16 at 22:19

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.