You're probably talking about Smooth Calibration right now, right?
It makes sense to carefully work through and understand the corresponding chapter "RTC smooth digital calibration" in the respective reference manual, especially because it also mentions other special features. For example, CALP cannot be set if PREDIV_A is less than 3.
In summary, the Smooth Digital Calibration works as follows:
- CALP: if set, 512 RTC clocks are added to a 32 second cycle, precisely a cycle of 2^20 RTC clock pulses
- CALM: the value of CALM is masked during a 32 second cycle, i.e. subtracted from the incoming RTC clock pulses
The reference manual also mentiones the formula [1] for fCAL:
fCAL = fRTCCLK x (CALPx512 - CALM)/(2^20 - CALPx512 + CALM)
where CALP can have the value 0 or 1 and CALM is in the range from 0...511
If you change this formula, you'll get [2]:
ppm = (CALPx512 - CALM)/(2^20 - CALPx512 + CALM) * 10^6
This results in the following table with the most important key figures:
- CALP=0, CALM=511 --> -511 = -487.10ppm
- CALP=0, CALM=000 --> -000 = 0.00ppm
- CALP=1, CALM=511 --> +001 = 0.95ppm
- CALP=1, CALM=000 --> +512 = +488.50ppm
If you want to convert a given temperature (ppm) curve into the values for CALM and CALP, you have to do this in two steps:
- first determine whether you have a negative deviation, which results in CALP=1, otherwise CALP=0,
- in the second step then determine CALM with the converted equation above [2]
Good luck!
/Peter
<edit>@TDK was faster... :beaming_face_with_smiling_eyes: </edit>
In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.