cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between RTC calibration output 1 Hz and 512 Hz

Joan Duran
Associate II
Posted on January 03, 2018 at 10:22

Hi,

I'm using a STM32L496VG, with an external LSE of 32768 Hz. I configure the RTC this way:

/* Enable Power Control clock */

__HAL_RCC_PWR_CLK_ENABLE();

/* Enable writing RTC back-up registers */

HAL_PWR_EnableBkUpAccess();

/* Configure RTC */

RtcHandle.Instance = RTC;

RtcHandle.Init.HourFormat = RTC_HOURFORMAT_24;

RtcHandle.Init.AsynchPrediv = RTC_ASYNCH_PREDIV;

RtcHandle.Init.SynchPrediv = RTC_SYNCH_PREDIV;

RtcHandle.Init.OutPut = RTC_OUTPUT_DISABLE;

RtcHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;

RtcHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;

HAL_RTC_Init(&RtcHandle);

and:

/* Configure the RTC clock source */

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;

RCC_OscInitStruct.LSEState = RCC_LSE_ON;

HAL_RCC_OscConfig(&RCC_OscInitStruct);

/* Select LSE as RTC clock source */

PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;

PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;

HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);

/* Enable RTC Clock */

__HAL_RCC_RTC_ENABLE();

In order to compensate the LSE drift, we output the RTC clock using HAL_RTCEx_SetCalibrationOutPut() function.

Using RTC_CALIBOUTPUT_1HZ we obtain 0.999951 Hz, which are 49 ppm drift, which is an expected value. But using RTC_CALIBOUTPUT_512HZ we obtain 508.022 Hz, which are 7769 ppm.

Also using an oscilloscope the output using RTC_CALIBOUTPUT_512HZ seems to be very unstable.

What's happening? Why there is such difference?

Thank you!

#rtc-calibration
0 REPLIES 0