I have an Arduino Mega and wondering if it’s possible to use it to count 17Mhz clock edges. I have a 17MHz clock and I’d like to send the clock through a passthrough board I made and out the other side using a signal generator.
I want to measure the clock edges from the signal generator before they enter the passthrough board and also at the output. Comparing them will tell me if I lost any. Is it possible to measure the input, the output, or ideally both with a Mega?
Possibly but not sure. The processor clock is 16 Mhz so measuring 17Mhz would have to be done by a hardware timer. I do not know the speed limit on the 16 bit timer counter. You would have to look. If it does you can count the rollovers and essentially reduce the time the processor has to measure by 2^16. However you still may not get enough resolution to meet your requirements.
What if I wanted to count all the clock edges of a 2MHz clock instead of 17MHz...I assume there is some type of interrupt on change pin that I can use to increment a counter?
The ESP32's I/O clock is set to 80Mhz, a 12.5 nanosecond pulse. The ESP32 has the PCNT, Pulse CouNTer module which can be programed under the Arduino IDE.