2021-05-19 09:07 PM
It will occur @here:
/** @addtogroup RTC_Private_Functions
* @{
*/
/**
* @brief Enter the RTC Initialization mode.
* @note The RTC Initialization mode is write protected, use the
* __HAL_RTC_WRITEPROTECTION_DISABLE() before calling this function.
* @param hrtc RTC handle
* @retval HAL status
*/
HAL_StatusTypeDef RTC_EnterInitMode(RTC_HandleTypeDef *hrtc)
{
uint32_t tickstart;
/* Check if the Initialization mode is set */
if ((hrtc->Instance->ISR & RTC_ISR_INITF) == 0U)
{
/* Set the Initialization mode */
hrtc->Instance->ISR = (uint32_t)RTC_INIT_MASK;
tickstart = HAL_GetTick();
/* Wait till RTC is in INIT state and if Time out is reached exit */
while ((hrtc->Instance->ISR & RTC_ISR_INITF) == 0U)
{
if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
{
return HAL_TIMEOUT;
}
}
}
return HAL_OK;
}
2021-05-19 11:59 PM
> I use the internal clock for rtc.
Do you mean LSI?
When the timeout happens, read out the RCC registers and check if that clock is running, and check if it is selected as RTC clock in RCC_BDCR.
JW
2021-05-20 12:17 AM
yes, i use LSI RC clock, when I debug again, it will not occur this error. i will focus on what you mean when it happen again.
2021-05-20 12:27 AM
After calling the function which returns the error, write a piece of program which checks for that error, and if the error happens, read out and store into an array in RAM the values of RCC registers. Then output these through your usual debugging method (look at it in debugger, send it to PC using UART, whatever you are normally using), and check the bits which are related to LSI and RTC.
You can do this also for the "working" state and then you can simply compare those two cases.
JW
2021-05-20 12:30 AM
ok, thanks a lot. you mean read the RCC registers can know what happened now about the RTC clock?