2011-02-25 05:38 AM
Sincronize stm32 clock with GPS?
2011-05-17 05:25 AM
I think the word you're looking for is synchronize.
But I'm not sure which clock you're looking to do that with, and to what accuracy. You'll need to define your question more precisely. It's certainly possible to get micro-second or so transfer using interrupts, sub micro-second if you code carefully. The bigger problem is the granularity of the RTC clock ticks, nominally 1 second. Which you can get sub-second if you pick a suitable divisor/prescaler, but still pretty course by most terms. You can measure/calibrate the HSI, HSE, LSI, LSE clocks, and compute their bias/drift relative to the GPS source, but your question leads me to believe you don't have any mechanism to steer or discipline them. The 40 KHz, and 8 MHz internal RC aren't all that stable in my honest opinion, and without a TCXO providing your primary frequency you're ability to hold-over in the absence of GPS isn't going to be terribly good. You could certainly measure the 1PPS period over some divided down version of the APB clocks, but the resolution will be somewhat degraded because you only have 16-bits to work with.