Hi
Don't forget that the day counter counts from 0..64k so it is necessary to add Gregorian date conversion when setting the data, and the opposite when displaying it. You don't seem to be using the data counter at the moment and you will have only time of day.
I think that you can simply set the time by doing the following:
MCF_RTC_HOURMIN_HOURS = hour; // alternatively (hour & 0x1f)
MCF_RTC_HOURMIN_MINUTES = minutes; // alternatively (minutes & 0x3f)
MCF_RTC_SECONDS_SECONDS = sec; // alternatively (minutes & 0x3f)
I didn't check the defines used above but basically there are 2 x 32 registers:
- SECONDS containing just seconds
- HOURMIN containing hours and minutes
I suspect that you have defines like RTC_HOURMIN_HOURS and RTC_HOURMIN_MINUTES allowing byte accesses to the corresponding parts of the HOURMIN register.
Alternatively you can probably do a single access to the complete register
MCF_RTC_HOURMIN = ((hour << 8) | minutes);
It seems that some of the code which you show is syntactically incorrect but also probably not relevant for what you want to do.
app_hw_m5223x.h is a hardware configuration file from the uTasker project (which you are not using). We are presently adding RTC support for the M5221X which has an external 32k crystal and battery back-up support, making the RTC much more attractive - here we also use Gregorian date conversions so that the calendar date is managed correctly. Our experience has shown that most M5223X projects with RTC requirements are solved by using an external RTC (eg. via I2C) with battery backup but this will certainly change with the battery backup support in newer devices.
Regards
Mark
www.uTasker.com