Hi there,
I have been experimenting with the cc430f6137's RTC module for quite some time now, initially in binary mode. For a couple of weeks now, the RTCDOW register was working just fine. I have done some testing involving future dates as well, and noticed nothing strange.
Then I switched my software to use RTC-A in BCD mode. It soon appeared that the current day-of-week was off by 2. That is to say, I compiled the code yesterday, Sunday, February 24, 2013 and the weekday displayed was TUE.
It turns out that the RTCDOW register, while returning 0..6 in binary mode, starting with Sunday (as per specification), seems to return incorrect values.
I tried to compensate in the following way (making the days of week start at Friday, rather than Sunday):
static char const * const rtca_dow_str[] = {
"FRI", "SAT", "SUN", "MON", "TUE", "WED", "THU"
};
This seemed to work okay, at first. However, going back a few days reveals that February 19, and February 20, are now both displayed as "WED".
Going into the future, February 28 is displayed as "THU" (as it should) but March 1 as "SUN". In this instance, it could be that the days of month were not considered correctly. Hard to tell. Something is clearly very wrong here. I did not encounter values outside the range of 0..6 so far. Just that the values returned seem very strange.
Is there any fix or workaround for this? I could not find this behavior in the errata sheet (revision C), either.
NOTE 1: Without my "fix", it would display Feb 24 "TUE", Feb 25 "WED", Feb 26 "THU", Feb 27 "FRI", Feb 28 "SAT" and Mar 1, "TUE" which is no less strange.
NOTE 2: If you initialized the value of the RTCDOW register, you must set a date at least once (without touching RTCDOW) for the register to get updated.