2022-07-05 01:40 AM
Hello,
I am having trouble calculating the correct calibration value for my RTC 32K osc. My setup is as follows.
STM32F411.
32768 LSE osc.
I am passing a 1HZ signal out of the micro and I am measuring it with a 5Mhz precision oscillator and counter, so if the RTC osc is perfect, I should get a count of 160,000,000 over the 32 second period.
What I actually get is a count of 159,969,776, this is a difference of 30,224 counts of 1/5mhz over a 32 second period.
This works out to be 0.0060448 seconds out per 32 second period.
So, i need to compensate for 0.0060448 seconds using 1/32768 clock cycles.
to find out this number i divide the period by the 32k clock period (0.0060448 / (1/32768) )= 198 clock cycles.
Because the 32768 clock is fast, i need to remove these clock cycles, so
my smooth calibration plus value = 0x00
and smooth calibration minus value = 0xc6
My problem is, when I re-measure the clock value, it is still out.
I have found that in this instance, a calibration value of
smooth calibration plus value = 0x00
smooth calibration minus value = 0xc1
works as expected and measures to be correct.
So my assumption is, I am making a mistake in my calculation.
Can you fault anything in my method or calculation?
Thanks for reading.
2022-07-05 04:13 AM
Your calculation seems to be OK, I see no reason for the difference.
Is LSE stable (i.e. are all readouts with the counter identical/close enough; after resetting RTC is the deviation still the same)? 190ppm is much more deviation than one would expect from a 32.768kHz crystal oscillator. Maybe you should start with checking your design, in particular the crystal's load capacitors. See AN2867.
JW
2022-07-05 02:22 PM
Frequency deviation of a LSE oscillator with ABS07W-32.768kHz-D-1 crystal on a two layer 1 mm board with different capacitors:
1,5 pF: +158 ppm
15 pF: -338 ppm
4,7 pF: -104 ppm
2,7 pF: +19 ppm
3,0 pF: +16 ppm
3,1 pF: +4 ppm