Skip to main content
Graduate
November 15, 2023
Question

Bug in STM32WBXX_HAL_RTC

  • November 15, 2023
  • 4 replies
  • 1577 views

As of version 1.12.0, HAL_RTC_Init uses a macro named __HAL_RTC_IS_CALENDAR_INITIALIZED. It is defined as follows:

#define __HAL_RTC_IS_CALENDAR_INITIALIZED(__HANDLE__) ((((RTC->ISR) & (RTC_ISR_INITS)) == RTC_ISR_INITS) ? 1U : 0U)

I suppose it should rather be 

#define __HAL_RTC_IS_CALENDAR_INITIALIZED(__HANDLE__) (((((__HANDLE__)->Instance->ISR) & (RTC_ISR_INITS)) == RTC_ISR_INITS) ? 1U : 0U)

 

    This topic has been closed for replies.

    4 replies

    Visitor II
    November 15, 2023

    I hope STM team will check this matter soon.

    Technical Moderator
    November 16, 2023

    Hello @LWChris ,

    I reported this issue internally for review .

    Internal ticket number: 166508 (This is an internal tracking number and is not accessible or usable by customers).

    Thank you.

    Kaouthar

    Technical Moderator
    November 20, 2023

    Hi @LWChris ,

    Both implementations are correct. No functional issue with these two implementations.

    Could you please give more details, if you found any issue when you used __HAL_RTC_IS_CALENDAR_INITIALIZED. 

    Thank you.

    Kaouthar

     

     

    LWChrisAuthor
    Graduate
    November 29, 2023

    Hi @KDJEM.1 

    I had no issues with the current implementation, but that is because hrtc->Instance is set to RTC. And I would assume this is probably the case for 99.9% of all projects. But if it wasn't, it would not have worked as intended.

    Since literally every other macro in HAL_RTC_Init actually uses the provided handle instead of assuming that __HANDLE__ is referring to RTC, and since the __HAL_RTC_IS_CALENDAR_INITIALIZED macro was only recently introduced in Cube V1.12.0, I found it to be likely a mistake that so far hadn't caused any problems because the default would always be the same.

    But in any way it doesn't look right for a macro to have a handle parameter that is subsequently ignored.