Electronic – How to set an oscilloscope for measurement of interrupt service routine execution time


I have been developing control software and I need to know how much time it takes to execute an interrupt service routine (ISR).

I have decided to use a dedicated GPIO pin of my microcontroller and an oscilloscope for that purpose. I set the pin to high at the beginning of the ISR execution and then reset it to low at the end of the ISR. I have configured my oscilloscope in such a manner that the trace record is triggered by the rising edge of the specified channel.

My idea was that, in case I measure the pulse duration via the oscilloscope, I will have the actual execution time of the ISR. This method works but I have found that the execution time fluctuates due to the internal logic in the ISR.

I would like to measure the worst case execution time but I am not sure how to set the trigger on my oscilloscope to be able to record the longest pulse. How can I do that?

Oscilloscope: Tektronix TDS2014

Best Answer

On TDS2014, the DISPLAY button menu includes persistence, which can be set to infinite. It should be able to capture the pulse-width of the GPIO signal.
If the ISR duration was constant, you should see a single pulse-fall, and a constant pulse-width assuming that trigger was set to start on the GPIO's rising edge.

Do ensure that your target ISR is not pre-empted by a different higher-priority ISR.