2018-08-08 02:15 PM
RTC_TimeTypeDef sTime;
RTC_DateTypeDef sDate;
sTime.TimeFormat = RTC_HOURFORMAT_24;
sTime.Hours = 12;
sTime.Minutes = 12;
sTime.Seconds=34;
sDate.Date=8;
sDate.Month=12;
sDate.Year=20;
HAL_RTC_SetTime(&RtcHandle, &sTime, RTC_FORMAT_BIN);
HAL_RTC_SetDate(&RtcHandle, &sDate, RTC_FORMAT_BIN);
HAL_Delay(5000);
HAL_RTC_GetTime(&RtcHandle, &sTime, RTC_FORMAT_BIN);
HAL_RTC_GetDate(&RtcHandle, &sDate, RTC_FORMAT_BIN);
printf("Time %02d:%02d:%02d\r\n",sTime.Hours,sTime.Minutes,sTime.Seconds);
printf("Date: %02d/%02d/%04d\r\n",sDate.Date,sDate.Month,sDate.Year+2000);
Time 12:12:38
Date: 08/12/2021
2018-08-09 12:57 PM
Read out and post the content of RTC_DR register.
Which Cube/HAL?
JW
2018-08-27 07:43 AM
Hi, I had this same problem.
Set the field sDate.WeekDay before calling HAL_RTC_SetDAte.
Ronald Benvenutti