2025-07-21 11:30 AM
Hi,
We're faced to an issue in the RTC module. RTC registers: time, date and backup register aren't saved after power off ( we measured the VBAT supply is about 3v given by the supercapa), we used a magic number to ensure that data aren't reinitialized at each software startup:
/** Initialize RTC Only
*/
hrtc.Instance = RTC;
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
hrtc.Init.AsynchPrediv = CFG_RTC_ASYNCH_PRESCALER;
hrtc.Init.SynchPrediv = CFG_RTC_SYNCH_PRESCALER;
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;
if (HAL_RTC_Init(&hrtc) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN Check_RTC_BKUP */
if(HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR0) == 0x55AA)
{
// Time and Date are OK
return;
}
/* USER CODE END Check_RTC_BKUP */
/** Initialize RTC and set the Time and Date
*/
sTime.Hours = 18;
sTime.Minutes = 4;
sTime.Seconds = 0;
sTime.SubSeconds = 0x0;
sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
sTime.StoreOperation = RTC_STOREOPERATION_RESET;
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK)
{
Error_Handler();
}
sDate.WeekDay = RTC_WEEKDAY_THURSDAY;
sDate.Month = RTC_MONTH_JUNE;
sDate.Date = 20;
sDate.Year = 24;
if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN RTC_Init 2 */
HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR0, 0x55AA);
Can you please give us some suggestions.
Thank you by advance,
Best regards,
Solved! Go to Solution.
2025-07-22 8:05 AM
Hello @freecoder,
This is probably a hardware issue...
If VBAT drops below 1.55V, the backup domain won't function correctly, so the RTC register content will be lost; are you sure the Vbat level is stable? can you share how VDDA/VREF+ is exactly connected?
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-07-22 8:05 AM
Hello @freecoder,
This is probably a hardware issue...
If VBAT drops below 1.55V, the backup domain won't function correctly, so the RTC register content will be lost; are you sure the Vbat level is stable? can you share how VDDA/VREF+ is exactly connected?
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-07-22 1:04 PM - edited 2025-07-23 11:27 AM