AnsweredAssumed Answered

time return always the same value

Question asked by collin.marc on May 1, 2015
Latest reply on May 2, 2015 by francescato.diego

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 


i get

Current 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?