When you call analogWriteFrequency(), you will only get the exact frequency requested if it divides evenly into the clock frequency of the timer that is generating the PWM signal. The pins used for PWM in Paul's sketch are 0,1,2,4,5, and those are all flexPWM, so the clock frequency is 150 MHz. The frequencies requested are listed below, along with the number of clocks per period for that frequency:
Code:
0 3 MHz 150/3 = 50
1 15 MHz 150/15 = 10
2 220 kHz 150/0.220 = 681.81
4 10 MHz 150/10 =15
5 455 kHz 150/0.455 = 329.67
Because 3, 15, 10 all divide evenly into 150, those PWM frequencies can be produced exactly. For the 220 kHz and 455 kHz, the divisor will be rounded, so the actual frequencies produced will be 150M/682 = 219941.35 and 150M/330 = 454545.45 Hz.
So, that's on the PWM (output) side. On the counting (input) side, each measurement is the number of rising edges seen in 200 ms. That's 1/5 second, so the frequency in Hz is the number of edges multiplied by 5. When I test the 455 kHz signal, I get mostly 454545, with some 454550. Is that what you mean by wander? What is happening is that the edge count can vary by 1, so the reported frequencies differ by 5. If you increase GATE_ACCUM from 100 to 500 and reduce MULT_FACTOR from 5 to 1, you will get a measurement every 1 second instead of every 200 ms, and the measurements will vary by only 1 Hz instead of 5. If measurement speed did not matter, you could measure over 100 seconds and get value with 0.01 Hz resolution, but that's a long time to wait.
If your lowest frequency is 100 kHz, then pulse counting with a gate period of 1 second seems reasonable.