craiglindley
Well-known member
OK, so I'm building a clock using the Teensy 3.1. This should be easy right ? Don't know if it is important or not but I'm running my clock in 12 hour format. So
1. I gather user input for the time and date and call setTime(hr, min, sec, day, mon, year) adjusting for 12 to 24 hour differences.
2. I read back the RTC and format a string for displaying time and date using the function below:
3. Things work well for about 5 minutes. That is, I read back the time and date correctly
4. Then I see this:
For some reason after 5 minutes the time mysteriously changes from 10:34 to 12:16 and my program is doing nothing excepting displaying the time.
I have a feeling this has something to do with syncing system time to RTC time but I don't know what.
Any hints would be appreciated
Thanks
1. I gather user input for the time and date and call setTime(hr, min, sec, day, mon, year) adjusting for 12 to 24 hour differences.
2. I read back the RTC and format a string for displaying time and date using the function below:
Code:
// Format the time and date into buffer in the form:
// hh:min AM/PM Mon Jan 31 2014
void formatTimeDate() {
boolean isAm = isAM();
time_t t = now(); // Get now time
int hr = hourFormat12();
int mi = minute(t);
int dy = day(t);
int weekDay = weekday(t);
int mo = month(t);
int yr = year(t);
sprintf(timeDateBuffer, "%d:%02d %s %s %s %d %d",
hr, mi, isAm ? "AM" : "PM", dayNameArray[weekDay], monthNameArray[mo], dy, yr);
Serial.println(timeDateBuffer);
}
3. Things work well for about 5 minutes. That is, I read back the time and date correctly
4. Then I see this:
Code:
10:32 AM Mon May 19 2014
10:33 AM Mon May 19 2014
10:33 AM Mon May 19 2014
10:33 AM Mon May 19 2014
10:34 AM Mon May 19 2014
10:34 AM Mon May 19 2014
10:34 AM Mon May 19 2014
10:34 AM Mon May 19 2014
12:16 AM Mon May 19 2014
12:16 AM Mon May 19 2014
12:16 AM Mon May 19 2014
For some reason after 5 minutes the time mysteriously changes from 10:34 to 12:16 and my program is doing nothing excepting displaying the time.
I have a feeling this has something to do with syncing system time to RTC time but I don't know what.
Any hints would be appreciated
Thanks