Nucleo H723 RTC under VBAT powering
Hello,
I have set an RTC on a Nucleo H7 board and i I am powering it via VBAT pin when i switch off the VDD on the board. I have removed the 0Ohm connector from the SB52 and everything since working fine. When I reset the board for instance and I keep in reset for 10 sec, for instance, when i restart the board the RTC has the timing set plus 10 secs which is the behaviour requested. The RTC is ticking when the board is in reset.
However if i unplug the VDD and I wait for instance 1 minute, as soon as I replug the RTC is keeping correctly the time but is not advancing; it stands still at the timing when i have unplug the VDD.
This is the only code i put in:
/**
* @brief RTC Initialization Function
* @param None
* @retval None
*/
static void MX_RTC_Init(void)
{
/* USER CODE BEGIN RTC_Init 0 */
/*
* Actions #1 and #2 are needed to resolve the default initialization
* of the RTC coming from the MX
*/
/* USER CODE END RTC_Init 0 */
RTC_TimeTypeDef sTime = {0};
RTC_DateTypeDef sDate = {0};
/* USER CODE BEGIN RTC_Init 1 */
/* USER CODE END RTC_Init 1 */
/** Initialize RTC Only
*/
hrtc.Instance = RTC;
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
hrtc.Init.AsynchPrediv = 127;
hrtc.Init.SynchPrediv = 255;
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;
if (HAL_RTC_Init(&hrtc) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN Check_RTC_BKUP */
// #1
// Get the time stamp from the RTC which is powered via external battery on VBAT
// store the value to the backup register
HAL_RTC_GetTime(&hrtc, &sTime, RTC_FORMAT_BIN);
HAL_RTC_GetDate(&hrtc, &sDate, RTC_FORMAT_BIN);
uint32_t timeStamp = 0;
timeStamp |= (sTime.Hours << 16) | (sTime.Minutes << 8) | sTime.Seconds;
HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR1, timeStamp);
uint32_t dateStamp = 0;
dateStamp |= (sDate.Date << 16) | (sDate.Month << 8) | sDate.Year;
HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR2, dateStamp);
/* USER CODE END Check_RTC_BKUP */
/** Initialize RTC and set the Time and Date
*/
sTime.Hours = 0;
sTime.Minutes = 0;
sTime.Seconds = 0;
sTime.DayLightSaving = RTC_DAYLIGHTSAVING_ADD1H;
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_NOVEMBER;
sDate.Date = 30;
sDate.Year = 22;
if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN RTC_Init 2 */
// #2
// Get the value from the backup register and set it to the RTC
sTime.Hours = (uint8_t)((HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR1) & 0xFF0000) >> 16);
sTime.Minutes = (uint8_t)((HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR1) & 0x00FF00) >> 8);
sTime.Seconds = (uint8_t)(HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR1) & 0x0000FF);
sDate.Date = (uint8_t)((HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR2) & 0xFF0000) >> 16);
sDate.Month = (uint8_t)((HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR2) & 0x00FF00) >> 8);
sDate.Year = (uint8_t)(HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR2) & 0x0000FF);
HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN);
HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN);
HAL_RTC_GetTime(&hrtc, &sTime, RTC_FORMAT_BIN);
HAL_RTC_GetDate(&hrtc, &sDate, RTC_FORMAT_BIN);
/* USER CODE END RTC_Init 2 */
}I have added action #1 and #2 just to workaround the MX code generated.
The battery is connected coupled with 2 caps for 1uf and 100nf as requested.
The RTC is clocked by the LSE.
It seems something is wrong in the ticking of the RTC as soon as the VDD is off but i can't figure out what it is.
Can someone help me please?
Thanks,
Filippo
