I have an application that I will develop that should log events and it needs to display the date-time stamp of these events.
I going to use PIC184620, and I am not so sure how to implement the date-clock, but here is what I am thinking:
1-The first time the user power the device up it will display something like:
01/01/2008 12:00AM
2-Then the user will have to set the actual date-time through menu.
3-In the C code I will have timer that runs once a minute. It will increment the minute, and if > 59 it increment the hour, and if > 11 it sets it either AM or PM Etc.
4-In the code I will have to hassle with issues like number of days in each month as well as leap years etc.
But the bigger problems are:
1- It is almost impossible to make an accurate C code 60-seconds timer.
2- What if the timer processing coincided or occurred at the same time while the processor is busy processing other interrupts, there will be delay, and that means eventually these delays will accumulate to make the time constantly off or lagging. The user will be constantly busy re-adjusting the time! One solution I could think of is to devote a second processor exclusively to the date-time, and make the main processor read the time from it (via serial or SPI or I2C etc) once every minute.
I am still in the thinking stage right now. I have not built anything yet, and if anyone had encountered this situation or has ideas, please let me know.
Thank You.