How to convert Accuracy(ppm) to CALP&CALM values when calibrate RTC ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-21 4:17 AM
How to convert Accuracy(ppm) to CALP&CALM values from Temperature-Accuracy graph from RTC Calibration by temperature ?
Solved! Go to Solution.
- Labels:
-
RTC
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-21 5:50 AM
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>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-21 5:33 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-21 5:43 AM
Thank you so much i will test it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-21 5:50 AM
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>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-21 5:50 AM
468,5 calculated by 488,5- 20 is not it ? if i want to adjust -15 ppm what should i do ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-21 5:53 AM
> if i want to adjust -15 ppm what should i do ?
CALP=0, CALM = 15/0.9537
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-21 6:48 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-25 12:20 AM
Is there a table listing CALP AND CALM value and ppm changes? I just want to get a quick table to look at. Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-25 7:51 AM
https://community.st.com/s/question/0D53W00001HGBevSAH/stm32-rtc-rtc-smooth-digital-calibration-is-there-a-table-listing-calpcalm-values-and-related-ppm-i-want-to-a-lookup-table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-09-09 2:31 AM - edited ‎2024-09-16 8:16 AM
