Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Measuring time of execution in routine

Status
Not open for further replies.

tom12sg

Member level 2
Joined
Feb 1, 2004
Messages
45
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,288
Activity points
422
Hi,

Any idea how can I measure the time of execution for routine written in C language under Keil complier?
In the target section I can specify the clock frequency used and the specific mcu to be used.
Under debugger I can see the dis-assembled code, but it would be a waste of time and very tire to calculate line by line and also some have different execution cycle. I have try the performance analyzer but it didn't give me the exact time in term of cycle... maybe I don't understand how to use it. I think Keil should have some means to calculate isn't, please someone teach and advice me.

Thanks.

Regards,
Tom
 

Maybe use a timer? I don't know what chip you are using, but if it comes to C, I think this is an easy method. Or use the simulator, if Keil has such a thing. I remember that HI-TECH's HI-TIDE could be used for doing this with PICs.
 

Hi tom12sg,

If you want(can), use a pin to mesure the period of the routine/function.

Cheers !
 

I think you must use the performance analyzer. It gives you the max, min and average times of execution.

Another solution (no so good) is to use breakpoints, before and after the function call. Then you must anotate the states and make a substration.

Regards,
 

nex said:
Hi tom12sg,

If you want(can), use a pin to mesure the period of the routine/function.

Cheers !

For this purpose, I using free CPU pin (or LED pin) and set logical "1" (or "0") on enter of subroutine (also Inerrupt service) or code fragment,
and set logical "0" (or "1") on exit or end of code fragment.
Then look by digital (or analog) oscilloscope this pin ....
This is easy and fast way to get programm timing.
 

Some assemblers have an option to count cycles. Perhaps yours does too.

Or maybe you can find one and feed it the segment of code you are interested in.

With some microprocessor families (like those with prefetches or pipelines) this is not a good indicator of actual execution time.

Interrupts, DMA, other bus-mastering devices, (maybe even integrated debug, I would have to check) can steal cycles during actual execution while devices with adjustable clocks might have wildly varying execution times even without cycle stealing.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top