The MCU used is a STM32F042 which is clocked by an OCXO oscillator (Abracon 10 MHz - 20 ppb). The subject of this thread is to get the best accuracy on one PPS Timer. For my application, I need to synchronize my MCU outdoors on the GPS PPS and then go indoors without any GPS Signals and keep my accurate PPS Signal.

I have a timer to get an interrupt every seconds. This interrupt has to be as close as possible to the GPS PPS. This GPS PPS is received on an interrupt pin which launch this process.

I synchronize my timer on the PPS reception but after one hour, my interrupt has drifted from 5 ms.

To get this result, here is the settings of the selected timer:

enter image description here

When I try the formula from ST which is: F timer = F clock / ( 1 + Prescaler ) * (1 + Period) with the following values : Prescaler = 199 and Period = 49999, the result is worst.

Anyone could help me? Thanks

  • \$\begingroup\$ Should it be 49750 - 1 = 49749 instead of 49999 ? \$\endgroup\$ Dec 13, 2019 at 14:28
  • \$\begingroup\$ To get 1Hz the theorical values are 199 and 49999 i think. \$\endgroup\$
    – Volt
    Dec 13, 2019 at 15:08
  • \$\begingroup\$ Today to be as close as possible to 1Hz, i have to put the values 200 and 49750 which normally give me 1,0000049Hz. \$\endgroup\$
    – Volt
    Dec 13, 2019 at 15:10
  • 1
    \$\begingroup\$ Clocks drift. You can and should fix implementation errors in your program, but your clock is still going to drift while you are without corrective inputs. Looking at the data sheet of your crystal, it has impressive stability but the accuracy is not inconsistent with the results you are achieving - look at the initial, initial, reflow, and aging. You may need to perform some sort of calibration. \$\endgroup\$ Dec 13, 2019 at 15:49
  • 1
    \$\begingroup\$ No, there is no promise that drift will be that low - you are misreading the promised stability as accuracy. \$\endgroup\$ Dec 13, 2019 at 15:55


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.