2019-09-23 08:40 AM
Hello everyone,
I have an application that synchronizes the RTC with the current time using a 3G module. Once it is synchronized, the system gets the date and time every 5 minutes in order to store sensor samples with a real timestamp. Everything is fine, but sometimes the value that I get using Get_Time from the RTC is incorrect (the year is 2035 for example).
It's very difficult to repeat the error and I cannot see where is the problem. Do you think that it could be a hardware problem (due to the possible noise produced by the 3G module affecting LSE crystal)? What other thing could produce these type of problems?
I'm using a STM32L451VCT6. And the initialization code is the following:
memset(&mainApp.newDateTime, 0, sizeof(Synchronization_DateTime_t));
mainApp.newDateTime.time_date.Year = MAINAPP_DEFAULT_DATE_YEAR;
mainApp.newDateTime.time_date.Month = MAINAPP_DEFAULT_DATE_MONTH;
mainApp.newDateTime.time_date.Date = MAINAPP_DEFAULT_DATE_DAY;
mainApp.newDateTime.time_date.WeekDay = RTC_WEEKDAY_MONDAY;
mainApp.newDateTime.time_time.Hours = MAINAPP_DEFAULT_HOUR_HOURS; mainApp.newDateTime.time_time.Minutes = MAINAPP_DEFAULT_HOUR_MINUTES;
mainApp.newDateTime.time_time.Seconds = MAINAPP_DEFAULT_HOUR_SECONDS;
mainApp.newDateTime.time_time.SubSeconds = MAINAPP_DEFAULT_HOUR_SUBSECONDS;
HAL_RTC_SetTime(timeManager.phrtc, &pNewDateTime->time_time, FORMAT_BIN );
HAL_RTC_SetDate(timeManager.phrtc, &pNewDateTime->time_date, FORMAT_BIN );
Any help will be appreciated.
Thank you very much.
Luis