Question
time return always the same value
Posted on May 01, 2015 at 15:48
hi
my rtc is initialized i set date and time. long getUnixTimestamp() { struct tm timeinfo; //Setup a tm structure based on the RTC timeinfo.tm_wday = dateStruct.WeekDay; timeinfo.tm_mon = dateStruct.Month - 1; timeinfo.tm_mday = dateStruct.Date; timeinfo.tm_year = dateStruct.Year + 100; timeinfo.tm_hour = timeStruct.Hours; timeinfo.tm_min = timeStruct.Minutes; timeinfo.tm_sec = timeStruct.Seconds; time_t rawtime = mktime(&timeinfo); printf(''Current date and time are: %s\n'', ctime(&rawtime)); long x = time(&rawtime); printf(''time %lu\n'', x); return x; } i do a call to HAL_RTC_GetTime HAL_RTC_GetDate getUnixTimestamp i getCurrent date and time are: Wed Apr 29 22:46:00 2015time 1430347560
5 second later, i do another call to HAL_RTC_GetTime, HAL_RTC_GetDate, getUnixTimestamp and getCurrent date and time return Wed Apr 29 22:46:05 2015 and time 1430347560
why time function value is not modified?
thanks #rtc #stm32f4 #discovery #time