Hello,
I am working on a project where I want to calculate the frequency of an input signal (90-110 KHz). I used a Function Generator(FG) to generate a square wave. FG is connected to pin 2 of Teensy 3.1.
I wrote the following code and I am able to display the correct frequency on the serial terminal. However when the input frequency is higher than 20KHz, the teensy doesn't display the right frequency even at the fastest clock. How can I fix this?
I decided to use Teensy 4.1 for this instead of 3.1. When I tried the same program on a 4.1, it doesn't even read the right frequency for 1Hz. It never read the right frequency. Not sure why. I even tried the common frequency for 3.1 and 4.1, 24MHz. Still, the discrepancy persists.
Is the 4.1 sampling rate worse than 3.1?
I also tried the code I found outline, the same problem persists. Till 20 Hz, it's fine. After that it's distorted.