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.

[SOLVED] Execution time computation of embedded C firmware

Status
Not open for further replies.

Momos1989

Junior Member level 2
Joined
Sep 26, 2012
Messages
24
Helped
1
Reputation
6
Reaction score
1
Trophy points
1,283
Activity points
1,439
Hello everyone! I make a firmware for a microcontroller, and now I would like to compute the time that take some Routines to end what they have to do. I've generated the Assembly code for the project, and I start computing the time taken by each instruction of the function! But it seems so long because in one Routine there is a Branching instructions!!

Is there any tool that let us know the time taken by a Routine by giving the Project source code??

And thank you :)
 

Why don't you use a timer interrupt and a flag? Set flag to 0 on start, start the timer counter, call the routine, on routine return set flag to 1 and stop timer. It will not be precise up to us, but still you'll have a very good estimated time of execution.
Another way is to take the whole assembly code and for each instruction consider the longest way the function could execute. This way you'll have the maximum time the function will take.
 

the second method is the one I did! but it's very long !!! :/ I have a very big project! and for each Function there is a call for other functions !! :/ for the 1st one it's not applicable on my case! :/ I have a lot of interrupts :/
 

Depending on what you need to calculate the execution time for, I think you can also follow all the instructions considering the shortest way the function could be executed. By knowing this time you know the function will take at least that minimum time to be executed, so you can never call it and expect it to end before that time.
By having the minimum and maximum execution time you have some good parameters to calibrate time for other tasks.

If you explain a bit what you need to calculate time for then probably someone can point you the right way. Also, I know some debuggers will count the function execution time at debug runtime but I don't know of any software capable of measuring the execution time given the source code.
 
Thank you! I made an approximation. I have generated the Assembly code of the project and then I counted for every instruction 2 cycles. so it gives me the approximation! :)
 

To be honest I don't think your solution is a good one, counting 2 instructions for each instruction means at least doubling the total time. Besides, it may give you a long enough time to perform other tasks in the meanwhile so it might actually work.
Well, good luck my friend :)
 

In my case I only want to be sure that my routines don't exceed some interval. so when saw that the assembly instructions in my case is between 1,2 and sometimes 3. So I took the average of those values, then the result was that the total doesn't exceed the time I wanted. So it was Ok ;) I know it's not accurate! but it works for my case.
Thank you friend :)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top