I just noticed the time in my software is jumping from May 30 to June 1 (Skips May 31). My hypothesis was that I had a month range error [1-12] instead of [0-11] causing the clock to think its the wrong month and thus the wrong number of days in each month. After testing all of my own libraries, I determined there were no problems. I then shifted focus to the rtc and calendar datatype, where I discovered the following:
On page 611 of SLAU208P (MSP430F5659 Userguide) the register RTCMON indicates the month range is [1-12]. On page 401 of the mspware driver library users guide (DOCNUM-2.91.03.00) the calendar datatype specifies a month range from [0-11]. Finally, within driverlib/MSP430F5xx_6xx/rtc_b.c, the functions RTC_B_initCalendar() and RTC_B_getCalendarTime() don't account for the month range conversion (See the attached code and documentation snippets).
It seems like there should be a month translation in the rtc_b functions. Is there merit to my findings, or am I missing something?
void RTC_B_initCalendar(uint16_t baseAddress,
Calendar *CalendarTime,
uint16_t formatSelect)
{
HWREG8(baseAddress + OFS_RTCCTL01_H) |= RTCHOLD_H;
HWREG16(baseAddress + OFS_RTCCTL01) &= ~(RTCBCD);
HWREG16(baseAddress + OFS_RTCCTL01) |= formatSelect;
HWREG8(baseAddress + OFS_RTCTIM0_L) = CalendarTime->Seconds;
HWREG8(baseAddress + OFS_RTCTIM0_H) = CalendarTime->Minutes;
HWREG8(baseAddress + OFS_RTCTIM1_L) = CalendarTime->Hours;
HWREG8(baseAddress + OFS_RTCTIM1_H) = CalendarTime->DayOfWeek;
HWREG8(baseAddress + OFS_RTCDATE_L) = CalendarTime->DayOfMonth;
HWREG8(baseAddress + OFS_RTCDATE_H) = CalendarTime->Month;
HWREG16(baseAddress + OFS_RTCYEAR) = CalendarTime->Year;
}
Calendar RTC_B_getCalendarTime(uint16_t baseAddress)
{
Calendar tempCal;
while(!(HWREG16(baseAddress + OFS_RTCCTL01) & RTCRDY))
{
;
}
tempCal.Seconds = HWREG8(baseAddress + OFS_RTCTIM0_L);
tempCal.Minutes = HWREG8(baseAddress + OFS_RTCTIM0_H);
tempCal.Hours = HWREG8(baseAddress + OFS_RTCTIM1_L);
tempCal.DayOfWeek = HWREG8(baseAddress + OFS_RTCTIM1_H);
tempCal.DayOfMonth = HWREG8(baseAddress + OFS_RTCDATE_L);
tempCal.Month = HWREG8(baseAddress + OFS_RTCDATE_H);
tempCal.Year = HWREG16(baseAddress + OFS_RTCYEAR);
return (tempCal);
}