cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F334 RTC Smooth Calibration

Manu Abraham
Senior
Posted on April 20, 2017 at 13:46

Hi,

Trying to calibrate the RTC, Using a LSE with 32768kHz xtal, which is running at a frequency of 32985.6Hz.

// with 32768Hz LSE, with AsynchPre=0x7f(128),

// CALIBOUT = 257.7Hz (measured on a scope)

// 32768/128 = 256Hz, but output is 257.7Hz

// 257.7Hz * 128 = 32985.6Hz

// error in this situation: +217.6 pulses

// 257.7 / 256.0 = 1.006640625

Doing smooth calibration with the CALM bits appeared to the straightforward choice to do the error correction.

So, I did

    // RTC Block diagram Fig:320 on Page #825 of the Reference Manual

    // RTC_OUT can either Output RTC_CALIB or RTC_ALARM

    // RTC_CALIB is either 1Hz or 512Hz, which is derived from RTCCLK

    // RTC_OUT, RTC_TS, RTC_TAMP1 are mapped to the same pin PC.13

    // RTC Calib Output on PC.13

    __GPIOC_CLK_ENABLE();                /* PC.13 CALIB_OUT    */

..

..

    RTC_CalibOutputConfig(RTC_CalibOutput_1Hz);

    RTC_CalibOutputCmd(ENABLE);            /* 1Hz on PC.13            */

    RTC_SmoothCalibConfig(RTC_SmoothCalibPeriod_8sec,

                  RTC_SmoothCalibPlusPulses_Reset,

                  RTC_CALR_CALM_7);        /* subtract 127 clocks        */

I get the very same frequency on PC.13, irrespective of the CALM bits.

Am I on the right path ?

Wondering whether the PC.13 pin is supposed to reflect the changes set by Smooth Calibration ?

Can someone clarify ?

Thanks!

2 REPLIES 2
luisf
Associate II
Posted on November 10, 2017 at 19:25

Got similar problem here on a STM32L433... despite the smooth calibration the rtc drift is the same as without any calibration. Any results on this?

Posted on April 04, 2018 at 12:48

Hi,

I guess the drift is probably due to the temperature dependency of the RTC crystal. In my observations over a period of many days, the crystal oscillation period during summer days is different from the cooler nights and so on. No amount of calibration can compensate for the drift in the crystal output. Additionally, another observation was that the calibration did not make any difference at all.