PaulStoffregen / FreqMeasure

Measures the elapsed time during each cycle of an input frequency.
http://www.pjrc.com/teensy/td_libs_FreqMeasure.html
72 stars 31 forks source link

[FreqMeasure] This software is being distributed under which license? #22

Open rtek1000 opened 2 years ago

rtek1000 commented 2 years ago

Hi,

I'm looking at the possibility of adding the frequency reading to an eeprom recorder to calibrate the RTC oscillator of the M48T12 memory.

https://github.com/moefh/eeprom_writer

The second approach is better suited for a manufacturing environment, and involves the use of a special test mode (as described in the section entitled, “Enabling the frequency test function (FT)” which derives a 512Hz signal from the clock divider chain, as indicated in Figure 2. This signal can be used to measure the accuracy of the crystal oscillator. The right-hand pair of columns in Table 1 on page 6 provides a look-up table similar to that in the left-hand pair of columns, except that the error values are expressed in “ppm” units instead of seconds per month. The error in ppm can be quickly calculated by dividing the measured error from 512 Hz by 512 and multiplying the result by 1 million. For example, if the frequency measured during the test mode is 511.998 Hz, the delta is –0.002. Dividing by 512 and multiplying by 1 million, the result is –3.906 ppm. In this case, the nearest compensation value is a +4.068. The appropriate sign bit in this case is a logical '1,' indicating the clock needs to speed up to compensate for the lost time. This yields a calibration value of “100001.”

https://www.st.com/resource/en/application_note/an934-how-to-use-the-digital-calibration-feature-in-timekeeper-and-serial--realtime-clock-rtc-products-stmicroelectronics.pdf

PaulStoffregen commented 2 years ago

https://github.com/PaulStoffregen/FreqMeasure/blob/22997104d4d988f7a71a7d4cc4be94a5416be9f4/FreqMeasure.cpp#L7

rtek1000 commented 2 years ago

Thanks, unfortunately it doesn't seem to be enough to read 512Hz with 0.001Hz offset.