This is the answerd form FREESCALE ENGINEER 1. If this method is used in main() then the result is not very accurate. This method is based on the interrupt - the PE uses a timer that periodically overflows in defined intervals. Overflow cause an interrupt where some internal variable is incremented. On the basis of this variable the PE calculates the time. But there are two sources of error: - resolution of timer - you have to add time that takes the execution of interrupt service routine of the timer. This ISR may be executed many times (depending on the resolution of timer)
So, you may get inaccurate time.
2. This method cannot be used to measure the running time of ISR. As I said before, this method is based on interrupt. Nested interrupts are not supported, so the timer ISR cannot be executed while you are waiting in another ISR! You will get zero result in this case.
The most efficient and very simple way is to toggle some pin at the start and at the end of the interrupt service routine and measure the interval by the oscilloscope. This is the most precise method not affected by software.
OR
Run the project in Full Chip Simulation. Step over the desired commands/functions. We can see the total number of "CPU cycles" in the Register window in debugger. I would like to note that this feature is available only in Full Chip Simulation (with all disadvantages of simulation).
PS. I will cancel the second service request because that's the same question.
Thank you for your interest in Freescale Semiconductor products and for the opportunity to serve you.
Should you need to contact us with regard to this message, please see the notes below. |