- 打卡等级:初来乍到
- 打卡总天数:4
- 最近打卡:2025-05-01 06:58:22
金牌会员
- 积分
- 1333
|
发表于 2024-8-19 16:58:49
|
显示全部楼层
Internal RC oscillators jitter by in the ball park of 1 part in 10,000, so that limits how 'exact' you can hope to be.
The CRE auto calibrate appears to sample SYSCLK at 32k/16, or 488.3us, but only has choices of 1ms-64ms correction rates, so it will lose long term tracking information, but may be good enough for some values of exact.
One example gives a CRE capture value of 16*40M/32678 = 19531.25, so choosing a value of 19531 will give a mean seek frequency of 39.999488MHz.
It will step by the trim step of ~ 0.3% but the long term average should be better than 0.3%, and may approach ~ 51ppm ( 1/19531) if the variations are random.
However, because the correction is always chasing the correct frequency short term variations may be worse than without the locking system enabled.
An alternative approach is to use the RTC 1/32 interrupt, to read a 24b timer, and keep an update of the long term difference.
eg a timer with a prescaler of /24 and read every 1/32 second at 40MHz will accumulate 40M/32/24 = 52083.33333 on average, so you can read to around 19ppm, far better than the one part in 10,000 of a RC oscillator. This reading will vary with voltage and temperature, but will not have the 0.3% jumps of the auto-calibrate.
|
|