AnsweredAssumed Answered

How to trim internal oscillator in SW?

Question asked by Grzegorz Kaczmarek on Apr 21, 2015
Latest reply on Apr 29, 2015 by Grzegorz Kaczmarek

Hello All,


I am designing a device (KL05) which needs to synchronize its clock (which source is based on internal 4MHz oscillator) to external reference signal got from RF module.

The idea is to timestamp incoming air packets in interrupt as they arrive and use sender's timestamp carried in a message payload.

Having such pairs of timestamps and some window of observation I'd like to run an algorithm for computing TRIM value for 4MHz oscillator to make it oscillate at nominal frequency.


Questions I have now are as below:

1. What would be the way for storing array of temperature and trim values in FLASH memory?

2. How do I program trim registers during code execution with data taken from array in FLASH (I'd like to react on temperature changes)?

3. How do I preserve my calibration data, not to lose it in case of FLASH memory erase?

4. Are there any simple algorithms for frequency calibration with small code footprint?


Thanks for any suggestions.


Best regards