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.

Optimization of execution time for embedded applications

Status
Not open for further replies.

Entwickler

Newbie level 2
Joined
Mar 28, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,302
Hello,
I am new to this forum, I am a developer in embedded systems.
I developed an application embedded in c and I am now at code optimization.
Then for the calculation of execution time of a function, I used 2 methods.
The first method, consits of using a LED.
At the beginning of the function I put this LED to 1 then I put this LED to 0 at the end oft he function.
Under this method, the execution time needed for this function is 2.12 µs.
The second method is to calculate the execution time based on the source code of thefunction in assembler (calculation of number of cycles required for execution of code),then taking everything into account gives 0.2 µs.
Then, the execution time of the function by the first method is 2.12 µs and according to the second method is 0.2us.
So my problem is to know why I have not had the same execution time of function in both methods.
How can I find the cause of the difference in execution time function for both methods?and how can I fix it?
Thank you very much
 

could the time for setting and clearing the LEDs be effecting the timing?
also check your clock setting

usually if I wish to time the execution of a function I would put it in a loop and call it a million times
This would then include the function call and parameter set up time, the function code and the overhead of the loop itself (which you could time by commenting out the function call)
 
Hi horace1,

please could you explain more the method used to calculate the function exécution, and have you a method to use when i would like to optimize my code,
best regards,
 

Hi horace1,
Thanks for the reply.
Actually, the time measured by the first method is 2.34 us including the time required for setting and Clearing the LEDs.
I took into consideration the time required for the operation of LEDs (which is 0.2 µs, ie 2.12 µs is the time necessary for the execution of the function independently of time necessary for the operation of LEDs).
Regarding your method, I have not understood :sad: , Can you explain a little more :-D?
Thank you very much
 

Are you taking in consideration the code in assembly itself? Like GOTOs and others? Whts the processor? Whts frequency it is running? According to your calculation, the code is running at 5Mhz end-to-end. Does that make sense for you? Any microcontroller with 16MIPS would achieve that with just 3 instructions, so anything bigger than that would result on a bigger time... and finally, are you sure your layout is ok to switch ar that frequency?

Cya
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top