Hello,
I am using MK22FN512 device and observed that the RTC deviates over a period of time so temperature compensation is required to correct the RTC.
Taking reference from application note AN4149 (attached) which is for Kinetis M device and datasheet of MK22FN512 have listed out the steps required below,
Please let me know if the steps are correct.
1. Read the temperature every 15 minutes using formula below
temp = 25 - (Vtemp - Vtemp25) / m))
Vtemp is current voltage measured
Vtemp25 is the voltage at 25DegC (this value is taken from datasheet)
m is the temperature sensor slope (this value is taken from datasheet)
temp is the measured temperature.
2. Calculate the frequency deviation using formula below
f = f0 [1 - 0.04ppm(T-T0) (T-T0)]
-0.04ppm is temperature coefficient as per crystal datasheet
T is measure ambient temperature
T0 is 25DegC
using above we get the temperature f and comparing to f0 which is 32768 we get the PPM error at temperature T i.e. (f0-f) will give the ppm error.
3. Using above PPM error in formula below,
PPM error = Tcr / (CIR + 1)
using this we get values of Tcr and CIR and we can set the values of the registers Tcr and CIR.
4. Wait for next 15 min cycle and repeat the above steps.
Thanks and Regards,
Anuj