in the code below which is mostly stolen from and old Teensy LC program that works fine,
the output seems to wander around (see output below). this happens with and w/o waiting
for an edge, with or w/o declaring the input pin as input (that is why all the commented out lines.
i have run a homemade freq meas that is pure software looking at that same pin w same vin,
fin, and protection resistor and numbers quite repeatable.

sq wave input goes 0.1 v to 3.1 v with 10k series protection resistor, tried 500 hz, 1khz, 1.5 khz

i found a reference in the forum that freqmeas uses pin 22 as input - could that have changed?
that same post showed good output from testing and signed off on freqmeas for T4
am i overlooking something?
is this really a bug?

here is the code:

Code:
#include <FreqMeasure.h>

volatile unsigned int fm,nm;
volatile unsigned short int rp1,rp2;
volatile unsigned short int wc;
volatile unsigned short int vc=2;

int main() {
//  pinMode(22, INPUT);
  Serial.begin(9600);
  delay(2000);
mloop:
// wait for pin 22 to change
//  goto skp;
//  wc=0;
//wtchg:
//  rp1=digitalReadFast(22);
//  delayMicroseconds(2);
//  rp2=digitalReadFast(22);
//  delayMicroseconds(2);
//  if (rp1==rp2) goto wtchg;
//  ++wc;
//  if (wc<vc) goto wtchg;
//skp:
//  pinMode(22, INPUT);
  FreqMeasure.begin();
fmeas:
  nm = FreqMeasure.available();
  if (!nm) goto fmeas;
  fm = FreqMeasure.read();
  FreqMeasure.end();
  Serial.println(fm);
  delay(5000);
  goto mloop;
}
here is the output:

Code:
65950
85325
29860
122921
119221
87416
31073
118509
112515
81163
28398
115655
112744
77425
46578
66131
102791
124760
131521
52774
82790
27665
121714
127578
47403
76589
18656
107765
105009
74826
18979
107823
109641
91503
49450
148374
95197
86666
58260
70732
91769
91935
71547
31934
129091
73530
69537