Skip to main content
Explorer
August 26, 2023
Solved

RTC TimeStamp

  • August 26, 2023
  • 1 reply
  • 2976 views

I use:
STM32Cube_FW_F4_V1.27.1
and CubeMx 6.9.0
I have a problem with the function HAL_RTCEx_GetTimeStamp(&hrtc, &RtcTimeTimeStamp, &RtcDateTimeStamp,RTC_FORMAT_BIN); it always returns the value 0 for the year, the other values are correct.

In the function I find:
/* Fill the Date structure fields with the read parameters */
sTimeStampDate->Year = 0U;
sTimeStampDate->Month = (uint8_t)((tmpdate & (RTC_TSDR_MT | RTC_TSDR_MU)) >> RTC_TSDR_MU_Pos);

    This topic has been closed for replies.
    Best answer by TDK

    The HAL_RTCEx_GetTimeStamp function reads the TSDR register as part of the time stamp feature. The TSDR register doesn't have a field for the year.

    This is different functionality than simply reading the date, which you can do with HAL_RTC_GetDate.

    1 reply

    TDKAnswer
    Super User
    August 26, 2023

    The HAL_RTCEx_GetTimeStamp function reads the TSDR register as part of the time stamp feature. The TSDR register doesn't have a field for the year.

    This is different functionality than simply reading the date, which you can do with HAL_RTC_GetDate.

    Explorer
    August 26, 2023

    THANKS