I'd want to use the RPi-pico to measure the ratio between two frequencies, one stable F0 = 10MHz, the other F1 about 14MHz, both externally fed to two GPIOs. 20 bit accuracy is fine. That could be e.g. counting over 21 bits how many F1 pulses there are over 220 pulses of F0.
Q0: Can one confirm the built-in Frequency Counter does the trick? I hope so based on
The frequency counter measures the frequency of internal and external clocks by counting the clock edges seen over a test interval. The interval is defined by counting cycles of clk_ref which must be driven either from XOSC or from a stable external source of known frequency.
Q1: How do I select the source of clk_ref
to make it my F0 = 10MHz from a GPIO?
Q2: Does that impact other things, in particular USB?
Q3: Are my 10 MHz and 14 MHz frequencies within parameters, and where is that specified?
Q4: Anything wrong in my understanding (below) of what the hardware does?
The doc of FC0_INTERVAL (4 bits) states
The test interval is 0.98us * 2interval, but let’s call it 1us * 2interval
The default (of 8) gives a test interval of 250us
I'm reading this as: the measurement interval is FC0_REF_KHZ * 2FC0_INTERVAL-10 periods of clk_ref
, somewhat rounded (for values of FC0_INTERVAL less than 10, some low-order bits of FC0_REF_KHZ are likely ignored).
The register FC0_RESULT (30 bits) is count * 215-FC0_INTERVAL where count is how many periods of the source selected by FC0_SRC there has been over the test interval.
I hope that's consistent with table 217 and the code for frequency_count_khz
.