cancel
Showing results for 
Search instead for 
Did you mean: 

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

werbung
Associate II

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
STTwo-32
ST Employee

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.

View solution in original post

1 REPLY 1
STTwo-32
ST Employee

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.