Hello everybody
I am trying to initialize the RTC_C on the MSP430FR5994 Launchpad by assigning values from the time library.
when I use hard coded values in 0x00 format, the downstream coding behaves differently than when I use the variable assignment
as shown below. I thought the problem was a type mismatch and tried casting, examining values etc but I am unable to resolve the
problem- calendar is not interpreting the variable assignment the same way as the hard coded values. My RTC initialization uses
binary so this is not a hexadecimal issue. The time lbirary fields (tm_sec, tm_min, etc) are integers while calendar fields are uint8_t.
any help is greatly appreciated.
thanks
jim
void Init_RTC() { struct tm *info; time_t rawtime; //type is long. used to hold encoded calendar time time(&rawtime); //function to get current system time relative to 1/1/1970 measured in seconds info=localtime(&rawtime); //returns pointer to tm structure that stores date and time mktime(info); //normalize values // really lame assignments for debug uint8_t sec =(uint8_t)(info->tm_sec); uint8_t min= (uint8_t)(info->tm_min); uint8_t hours = (uint8_t)(info->tm_hour); uint8_t weekDay = (uint8_t)(info->tm_wday); uint8_t month = (uint8_t)(info->tm_mon); uint8_t dayOfmonth = (uint8_t)(info->tm_mday); uint8_t year = (uint8_t)(info->tm_year); //Setup Current Time for Calendar calendar.Seconds = sec; //0x25; calendar.Minutes = min; //0x05; calendar.Hours = hours; //0x0C; //12 calendar.DayOfWeek = weekDay;//0x00; calendar.DayOfMonth = month;//0x05; calendar.Month = month+1;//0x02; calendar.Year = 0x07e3; //0x2019; // Initialize RTC with the specified Calendar above RTC_C_initCalendar(RTC_C_BASE, &calendar, RTC_C_FORMAT_BINARY); //using RTC_C_FORMAT_BCD scrambles file time stamp RTC_C_setCalendarEvent(RTC_C_BASE, RTC_C_CALENDAREVENT_MINUTECHANGE ); RTC_C_clearInterrupt(RTC_C_BASE, RTC_C_TIME_EVENT_INTERRUPT ); RTC_C_enableInterrupt(RTC_C_BASE, RTC_C_TIME_EVENT_INTERRUPT ); //Start RTC Clock RTC_C_startClock(RTC_C_BASE); }