Skip to main content
Visitor II
June 2, 2021
Solved

Is there any way to disable the RTC reset on STM32F476

  • June 2, 2021
  • 3 replies
  • 1282 views

The HAL RTC initialization routines for the STM32F476 unconditionally reset the clock to

January 1, 2000. I have a battery backup for the clock and do not want the clock reset on initialization.

Has anybody found a way to do this within the CubeMX framework?

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

    Within MX_RTC_Init, exit the function if the RTC is already configured

    /**
     * @brief RTC Initialization Function
     * @param None
     * @retval None
     */
    static void MX_RTC_Init(void)
    {
     
     /* USER CODE BEGIN RTC_Init 0 */
     if (already configured and running) {
     return;
     }
     /* USER CODE END RTC_Init 0 */
     ...

    .

    3 replies

    GJohnAuthor
    Visitor II
    June 2, 2021

    Sorry folks. I'm using a STM32F429, and NOT STM32F476.

    TDKAnswer
    Super User
    June 2, 2021

    Within MX_RTC_Init, exit the function if the RTC is already configured

    /**
     * @brief RTC Initialization Function
     * @param None
     * @retval None
     */
    static void MX_RTC_Init(void)
    {
     
     /* USER CODE BEGIN RTC_Init 0 */
     if (already configured and running) {
     return;
     }
     /* USER CODE END RTC_Init 0 */
     ...

    .

    GJohnAuthor
    Visitor II
    June 2, 2021

    You're correct. I overlooked those user code blocks. Thanks.