2022-08-05 06:28 AM
In the following HAL function, RTC ISR register is cleared by "Read/Modify/Write" instruction.
Couldn't this cause eventual clearing of the ISR flags which may be raised by RTC periphery between "load" AND "store" ?
If somebody can confirm that such situation may happen, wouldn't be safer solution to rather write all other bits to "1", since ISR register has only of read-only or clear-only bits or reserved bits?
AL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc)
{
uint32_t tickstart;
/* Clear RSF flag */
hrtc->Instance->ISR &= (uint32_t)RTC_RSF_MASK;
AL_StatusTypeDef HAL_RTC_WaitForSynchro(RTC_HandleTypeDef *hrtc)
{
uint32_t tickstart;
/* Clear RSF flag */
hrtc->Instance->ISR &= (uint32_t)RTC_RSF_MASK;
Solved! Go to Solution.
2022-08-05 07:45 AM
Hello MPrud.1,
I agree with you. Due to the Read-Modify-Write (RMW) sequence in HAL_RTC_WaitForSynchro function, it can also clear accidentally flags which arrive after the READ.
I will internally suggest to remove the AND combination:
hrtc->Instance->ISR = (uint32_t)RTC_RSF_MASK;
Thanks for raising this point.
Best regards
Michael
2022-08-05 07:45 AM
Hello MPrud.1,
I agree with you. Due to the Read-Modify-Write (RMW) sequence in HAL_RTC_WaitForSynchro function, it can also clear accidentally flags which arrive after the READ.
I will internally suggest to remove the AND combination:
hrtc->Instance->ISR = (uint32_t)RTC_RSF_MASK;
Thanks for raising this point.
Best regards
Michael
2022-08-05 07:49 AM
Thx for very quick answer.
Regards,
Mirek