I'm new to doing embedded development, but have been working on an application for the F5342 chip. The program needs to have a real-time clock, and will spend most of its time in LPM3, waking up twice a second to do a little work.
I'm using DriverLib, and used the rtc_a_ex1_calendarmode example. To initialize the clock, this is basically what happens:
Calendar current; // initialize current with the current time RTC_A_holdClock(RTC_A_BASE); RTC_A_calendarInit(RTC_A_BASE, current, RTC_A_FORMAT_BINARY); RTC_A_startClock(RTC_A_BASE);
Then to read the clock it just does this:
Calendar current = RTC_A_getCalendarTime(RTC_A_BASE);
The trouble is that it's not very accurate. It's been running about 1 hour, and the clock has already gained about 40 seconds.
So I guess there needs to be some calibration applied, but after reading a number of posts on similar problems, and being new to developing for this chip, it's not clear to me just what I should do.
Some posts seem to imply there should be an additional clock used that is more accurate than the A clock, but I need to use LPM3 and there's no additional clock available.
I have tried doing this:
RTC_A_setCalibrationData(RTC_A_BASE, RTC_A_CALIBRATION_DOWN2PPM, 63);
And it seems to have slowed things down but it's still gaining about 20 seconds an hour.
At this point, I'm not sure what to else do. How can I make the clock more accurate?
Thanks for your help,