2025-02-10 10:56 AM
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
Solved! Go to Solution.
2025-02-11 8:45 AM - edited 2025-02-11 8:45 AM
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
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-02-11 8:45 AM - edited 2025-02-11 8:45 AM
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
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.