Skip to main content
werbung
Associate II
February 10, 2025
Solved

STM32H5xx - CUBE MX 6.13 - Error activating RTC Clock source for Backup register access

  • February 10, 2025
  • 1 reply
  • 504 views

Cube MX: After RTC configuration with "activate clock source" and running the Cube generated Code  the RTC wont start.

TheCube MX generated code  is missing to set the RTCAPBEN Bit in the RCC->APB3ENR Register.

I found out that the  "stm32h5xx_hal_rtc.c"  hal  driver  doesnt work correct.:

The driver states:   "Call the function HAL_RCCEx_PeriphCLKConfig with RCC_PERIPHCLK_RTC for
PeriphClockSelection and select RTCClockSelection (LSE, LSI or HSEdiv32)
(+) Enable RTC Clock using the __HAL_RCC_RTC_ENABLE() function."

This is called by the Cube output but this doesnt set the RCC Clock bit for the RTC to "1" . It stays "0"

Workaround:   Set the RTCAPBEN Bit   in   RCC->APB3ENR  manualy.

 

Regards Henry

 

Best answer by STTwo-32

Hello @werbung 

On the HAL_RTC_MspInit function, the STM32CubeMX generate a call for both "__HAL_RCC_RTC_ENABLE()" and "__HAL_RCC_RTCAPB_CLK_ENABLE()" It is the "__HAL_RCC_RTCAPB_CLK_ENABLE();" call that set the  RTCAPBEN Bit in the RCC->APB3ENR register. I've tested on the NUCLEO-H563ZI and it works fine (set the RTCAPBEN to 1 when called).

Best Regards.

STTwo-32

1 reply

STTwo-32
STTwo-32Best answer
Technical Moderator
February 11, 2025

Hello @werbung 

On the HAL_RTC_MspInit function, the STM32CubeMX generate a call for both "__HAL_RCC_RTC_ENABLE()" and "__HAL_RCC_RTCAPB_CLK_ENABLE()" It is the "__HAL_RCC_RTCAPB_CLK_ENABLE();" call that set the  RTCAPBEN Bit in the RCC->APB3ENR register. I've tested on the NUCLEO-H563ZI and it works fine (set the RTCAPBEN to 1 when called).

Best Regards.

STTwo-32