Measuring Execution Time for a Piece of Code

Hi Jeff,

Thanks for the suggestion. I have actually already looked into using this library. As far as I can tell the maximum possible frequency (set a timer to execute a single instruction) is limited somewhere below 4 MHz which is what I need to get for this as I need to sample a pin to collect data from a sensor and I don't want to miss any bits.

If you know of any way to get the cycling frequency >4 MHz that would be awesome.

Thanks again for the quick response.

UPDATE: I did some quick testing and it seems the library (in its current state) can only do frequencies up to 1 MHz (Period of 1 us)
Also the code of interest is a single piece of code in a much larger loop and so as a result using the timer method would not be a good solution.

Ideally I would like to get this done by writing the appropriate number of NOP's to occupy the time until the next piece of code has to run, but I don't know how to figure out how many NOP's I need to do that.

Thanks