My program needs to run at the maximum speed the Arduino can provide and I'm now in the need of a high precision timing function. The built-in micros() is only accurate for microseconds, but I'd like to measure as precise as a single instruction.
I've looked at the source code of the built-in timing stuff, but I can't figure out how to adjust it for more precision. It would be awesome if you could provide me with some code do do this.
I think you need external hardware to measure that precisely.
You can set a fuse to output the system clock on PortB-0, 62.5nS.
Run that thru an 2-input AND gate, with your to-be-measured signal as the other input.
Use the hardware counters to count how many occurrences of clock come out while your signal is high.