cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Observer
Observer
10,622 Views
Registered: ‎09-26-2007

how to calculate the time that the processor spent for executing several lines in an application?

hi,
 
I tried to take the advantage of the interrupt in an application. However, I found when the processor run the lines in the interrupt handler code, it missed some other interrupt signals.
 
Since these interrupt signals were created by a VHDL module, and they woundn't be stopped even when the interrupt event has been processing. While in the interrup handler code, I have to reset the global interrupt signals before processing the interrupt event.  So I have to know how long the interrupt handler would take during it processed the interrupt event.
 
Could anybody tell me how to calculate the time that the processor spent for executing several lines in an application?
 
Thank you for your consideration and help!
0 Kudos
Reply
5 Replies
Explorer
Explorer
10,595 Views
Registered: ‎08-14-2007

Hi,

Can you use a GPIO port?  Toggle some pins at various points in the code, and then conenct a scope up to them.

Or put a timer peripheral in your design and sample that before and after the appropriate lines of code.  Depends on the resolution you require (and if all the code is "together").

I prefer the scope solution most of the time (but maybe that's my HW bias :-)

Cheers,
Martin  
Martin Thompson
martin.j.thompson@trw.com
http://www.conekt.co.uk/capabilities/electronic-hardware
0 Kudos
Reply
Observer
Observer
10,586 Views
Registered: ‎09-26-2007

I'll try it with your suggestion! Thank you very much!
0 Kudos
Reply
Xilinx Employee
Xilinx Employee
10,583 Views
Registered: ‎08-06-2007

Hi,
 
If you are using MicroBlaze and don't disable interrupts in your main code, there is a way to measure the time spent in the interrupt handler by looking at the trace output of the MSR register.
There is a trace output signal from MicroBlaze called trace_msr_reg which has the value of the internal MSR register.
In the MSR register there is a Interrupt Enable bit (IE) which is cleared when taking an interrupt and enabled again when returning from the interrupt handler.
 
So unless you sometimes disable interrupts in your code, the status of this bit reflect exactly the time spent in the interrupt handler.
By using this bit, you don't have to modify your code.
 
Göran Bilski
0 Kudos
Reply
Observer
Observer
10,570 Views
Registered: ‎09-26-2007

Göran Bilski,
 
Your solution is great I guess since I needn't change my code if this way works. However, I used PPC405 now. Maybe it can't be used, is it correct?
 
Thank you for your help!
0 Kudos
Reply
Observer
Observer
4,358 Views
Registered: ‎12-12-2007

I want to ask something irrelevant to the topic. Is there any documentation about these trace signals and specifically for that trace_msr_reg? I mean which bit of this signal corresponds to which bit of the MSR?

 

Thanks,

Nikos

0 Kudos
Reply