Skip to main content
Graduate
August 28, 2025
Solved

STM32C071 LL RTC Deinit error when BYPSHAD enabled

  • August 28, 2025
  • 3 replies
  • 379 views

Hello,
In the STM32CubeC0 v1.4.0, when I enable the BYPSHAD bit in the CR register and later try to deinit the device, I get an ERROR. It does not happen if I disable it before deinitialising. Should I disable it by hand, or is it a mistake and should be cleared as in other families? HAL version is clearing the whole register to the reset value when deinitialising.

Best regards,

Tomáš

    This topic has been closed for replies.
    Best answer by Saket_Om

    Hello @Tomáš Juřena 

    The issue has been resolved, and the fix is now available on GitHub via the link below:

    [LL][RTC] Add instruction to clear CR register in LL_RTC_DeInit() to … · STMicroelectronics/stm32c0xx-hal-driver@d51d6e7

    3 replies

    Technical Moderator
    August 29, 2025

    Hello @Tomáš Juřena 

    The RTC Control Register (CR) is cleared at the beginning of the HAL_DeInit() function.

    What type of error are you encountering, and which instruction is returning this error?

    Graduate
    August 29, 2025

    Hi,

    I have noticed that I mentioned I use LL libraries only in the post subject. Let me try to clarify this.

    The function call LL_RTC_DeInit returns an ERROR value when I enable the BYPSHAD bit beforehand. If I do not enable the bypass function or disable it before calling the LL_RTC_DeInit function, the SUCCESS value is returned.

    I got the timeout in LL_RTC_WaitForSynchro at stm32c0xx_ll_rtc.c:682.

    Best regards,

    Tomáš

     

    Technical Moderator
    August 29, 2025

    Hello @Tomáš Juřena 

    Thank you for bringing this issue to our attention.

    I reported this internally.

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

    Super User
    September 4, 2025

    Looking at stm32c0xx_ll_rtc.c, in LL_RTC_DeInit(), LL_RTC_WaitForSynchro() is called "unconditionally", whereas all other calls of LL_RTC_WaitForSynchro() (in LL_RTC_TIME_Init() and in LL_RTC_DATE_Init()) are guarded by LL_RTC_IsShadowRegBypassEnabled().

    So yes, I'd call it a bug, and I'd expect it to go across all STM32 families' Cube/LL.

    As Cube is open source, you can fix it yourself, by adding the same guard to LL_RTC_DeInit().[EDIT] On second thought, IMO the guard should be moved into LL_RTC_WaitForSynchro() itself. [/EDIT]

    Another solution may be to avoid calling LL_RTC_DeInit() and resetting the whole backup domain through RCC_BDCR.BDRST. I don't use Cube so don't know if there's any ready-made function for that.

    JW

    Saket_OmAnswer
    Technical Moderator
    November 7, 2025

    Hello @Tomáš Juřena 

    The issue has been resolved, and the fix is now available on GitHub via the link below:

    [LL][RTC] Add instruction to clear CR register in LL_RTC_DeInit() to … · STMicroelectronics/stm32c0xx-hal-driver@d51d6e7