Skip to main content
GJohn
Associate III
Jun 2, 2021 3:01 AM UTC
Solved

Is there any way to disable the RTC reset on STM32F476

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.
TDK
TDKBest answer
Jun 2, 2021 3:16 AM UTC

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 */
 ...

.

"If you feel a post has answered your question, please click ""Accept as Solution""."

3 replies

GJohn
GJohnAuthor
Associate III
Jun 2, 2021 3:15 AM UTC

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

TDK
TDKBest answer
Jun 2, 2021 3:16 AM UTC

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 */
 ...

.

"If you feel a post has answered your question, please click ""Accept as Solution""."
GJohn
GJohnAuthor
Associate III
Jun 2, 2021 3:38 AM UTC

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