cancel
Showing results for 
Search instead for 
Did you mean: 

Periodic RTC calibration STM32F1xx

eliast1234
Associate II
Posted on April 08, 2015 at 15:56

Hello,

MyProject: Calibrate RTC LSE clock continuously based on an external time reference.

MyProblem: Calculation of re-calibration value.

Description: I start a calibration measurement interval time t1 and stop it at t2. These two are reference times. I also note the corresponding RTC times t1_rtc and t2_rtc.

Based on these values I calculate the time difference in PPM and and adjust my RTC prescaler and calibration value, e.g., call them ''PS_OLD'' and ''CAL_OLD''. This works fine since I have no calibration value in RTCCR register.

Like this, I want to do periodic measurements and repeat the calibration, for example every 10 days or weekly.

Problem: I do not know how to calculate the new calibration value, if I have already a calibration value in RTCCR register; e.g., calculation of new prescaler and calibration value PS_NEW and CAL_NEW?

hope I was able to illustrate the problem and thanks for any contribution...

10 REPLIES 10
eliast1234
Associate II
Posted on April 11, 2015 at 07:46

Hello Mr. clive1,

I am now able to understand your second and fourth posts perfectly:

I think now in terms of total generated ticky by the crystal which remains same in both. Generating a new PSC and PPM from the previous calibration stage is just a new interpretation (refactoring) of the same number of ticks to get the new set.

Thank you again for your much appreciated contribution!