cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F411 RTC 32768 cal Freq only 490Hz

erastusC
Associate III

Post Edited by ST moderator to apply source code formatting to comply with the community rule:


I wonder if any one can help me.

The rtc Cal freq produced by the init code below produces on 490Hz.  The RTC clock is loosing about 55 sec in 20 minutes.

Is there a way to increase this freq without replacing the crystal?

 

 
static void MX_RTC_Init(void)

{

/* USER CODE BEGIN RTC_Init 0 */

/* USER CODE END RTC_Init 0 */



RTC_TimeTypeDef sTime = {0};

RTC_DateTypeDef sDate = {0};

/* USER CODE BEGIN RTC_Init 1 */

/* USER CODE END RTC_Init 1 */

/** Initialize RTC Only */

hrtc.Instance = RTC;

hrtc.Init.HourFormat = RTC_HOURFORMAT_24;

hrtc.Init.AsynchPrediv = 127;

hrtc.Init.SynchPrediv = 255;

hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;

hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;

hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;

if (HAL_RTC_Init(&hrtc) != HAL_OK)

{

Error_Handler();

}



/* USER CODE BEGIN Check_RTC_BKUP */



/* USER CODE END Check_RTC_BKUP */



/** Initialize RTC and set the Time and Date

*/

sTime.Hours = 18;

sTime.Minutes = 4;

sTime.Seconds = 11;

sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;

sTime.StoreOperation = RTC_STOREOPERATION_RESET;

if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK)

{

Error_Handler();

}

sDate.WeekDay = RTC_WEEKDAY_SATURDAY;

sDate.Month = RTC_MONTH_JANUARY;

sDate.Date = 24;

sDate.Year = 26;



if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN) != HAL_OK)

{

Error_Handler();

}



/** Enable Calibrartion

*/

if (HAL_RTCEx_SetCalibrationOutPut(&hrtc, RTC_CALIBOUTPUT_512HZ) != HAL_OK)

{

Error_Handler();

}

/* USER CODE BEGIN RTC_Init 2 */



/* USER CODE END RTC_Init 2 */



}

 

 

Thank you

11 REPLIES 11

Thank you so much for your response.

 

Yes it is either a hardware or software issue.  What I did is I calculated the error and then every x minutes did a correction by using a counter for minute errors and every day I corrected the seconds with a final value.  So I have an error now of +/- 1 sec per week.

So that sorted the software or hardware issue STM has.

The stuff Peter explained did not work on the board I have

So I now added a small RS485 with a RTC correction from the main system via a protocol.

One does not always know if it is software or hardware issue.

 

STM assistance is not worth mentioning.

Thanks for your info