View previous topic :: View next topic |
Author |
Message |
TobyHarris
Joined: 27 Sep 2007 Posts: 5
|
Setting RTC |
Posted: Thu Oct 04, 2007 7:19 am |
|
|
Hi
Having done endless searches, I have found lots of information on reading and writing to RTCs (In particular the DS1307 I'm using). Whilst this is good, I have found nothing on the subject of actually setting the RTC in the first place to the correct time/date.
I assume this has to have some sort of user interface, but I'm getting stuck at working out how to do this efficiently with appropriate error handling - for example setting incorrect number of days for given month).
Can anyone help me out ?
(I have several buttons and an LCD display available!) |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Thu Oct 04, 2007 8:29 am |
|
|
Yes. If you need to regularly set the RTC, you will need an 'external' interface to the world. It can be anything from a set of switches to toggle between fields and increase or decrease values. Or you can add a serial interface that will accept input for setting the RTC. Or, when I don't have an external interface I add a temporary set function to my firmware for one load. I time it so I power up the part at the precise time that will be set. (You've also got to ensure that you have your battery backup in place.)
Decide what your system will allow... simple push-buttons, serial interface, etc., and then it will be easy to help.
John
Here is a good example of a command parser:
http://www.ccsinfo.com/forum/viewtopic.php?t=28159&highlight=command+parser |
|
|
TobyHarris
Joined: 27 Sep 2007 Posts: 5
|
|
Posted: Thu Oct 04, 2007 8:52 am |
|
|
Hi John
As stated there are a couple of push to make switches and a 16x2 LCD display. There is no external serial interface present, therefore my solution needs to be entirely on-board using the buttons and LCD.
My problem is how to form a nice user interface which takes into consideration that the user might set the day to 31 and then set the month to one which only has 30 days... |
|
|
|