Skip to main content
oziesin
Associate III
December 21, 2021
Solved

How to convert Accuracy(ppm) to CALP&CALM values when calibrate RTC ?

  • December 21, 2021
  • 6 replies
  • 5414 views

How to convert Accuracy(ppm) to CALP&CALM values from Temperature-Accuracy graph from RTC Calibration by temperature ?0693W00000HpMuGQAV.png

Best answer by Peter BENSCH

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:

  1. first determine whether you have a negative deviation, which results in CALP=1, otherwise CALP=0,
  2. 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>

6 replies

TDK
December 21, 2021

Per the reference manual, CALP increases the frequency by 488.5 ppm and CALM decreases it by 0.9537ppm per count.

So if you want to adjust by +20ppm, CALP=1, CALM=468.5/0.9537=491.

0693W00000HpNbBQAV.png

"If you feel a post has answered your question, please click ""Accept as Solution""."
oziesin
oziesinAuthor
Associate III
December 21, 2021

Thank you so much i will test it.

Peter BENSCH
Peter BENSCHBest answer
ST Technical Moderator
December 21, 2021

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:

  1. first determine whether you have a negative deviation, which results in CALP=1, otherwise CALP=0,
  2. 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.
waclawek.jan
Super User
December 21, 2021

Nicely put, Peter.

I wonder, why such a straghforward explanation can't be part of AN4759. Yes, it's there, sort of; but as a practical example, your explanation above is IMO better than anything which is there.

JW

oziesin
oziesinAuthor
Associate III
December 21, 2021

468,5 calculated by 488,5- 20 is not it ? if i want to adjust -15 ppm what should i do ?

TDK
December 21, 2021

> if i want to adjust -15 ppm what should i do ?

CALP=0, CALM = 15/0.9537

"If you feel a post has answered your question, please click ""Accept as Solution""."
AJian.3
Associate
December 25, 2021

Is there a table listing CALP AND CALM value and ppm changes? I just want to get a quick table to look at. Thanks.

TDK
December 25, 2021
"If you feel a post has answered your question, please click ""Accept as Solution""."