|
|
View previous topic :: View next topic |
Author |
Message |
ferkar
Joined: 14 Jul 2007 Posts: 38
|
how could i measure the total time for executing the code? |
Posted: Mon Mar 24, 2008 9:28 am |
|
|
hi again dear friends,
i would like to know how long does the total code execution that is in the microcontroller ?
and another question,
for example , if wrote like this:
..
..
..
for(x=1;x<10;x++){
set_pwm1_duty(250)
}
..
..
..
the question is:
what will happen after the for() cycle?
is the pwm module becomes off or keeps the last value on it? |
|
|
Ttelmah Guest
|
|
Posted: Mon Mar 24, 2008 10:09 am |
|
|
A number of choices:
1) Set a pin before a particular code block, clear it afterwards, run the code, and time it. Reliable, and 'real'.
2) Look at the assembler listing, and calculate the instruction times. Accurate, but hard work.
3) Run the code in a ICE system, that has the ability to time blocks. Easy, but expensive.
4) Run the code in a simulator (MPLAB), and use it's stopwatch ability.
On the pwm, the value given in the 'set_pwm_duty' instruction, takes effect on the _next_ cycle of the PWM, then remains in effect till the PWM is stopped, or a new value is given. The odds are that the code as posted, just wastes quite a few cycles of the processor clock, since the PWM value will be changed nine times, but will probably have updated only once, if at all.
Guess at a total time of about a dozen instructions per loop.
Best Wishes |
|
|
baltazar_aquino
Joined: 16 Mar 2008 Posts: 27
|
|
Posted: Mon Mar 24, 2008 11:42 am |
|
|
during my programming days with DOS, the way to measure execution time is to restart a counter before executing a block of code then at the end of the block you read again the counter then calculate against the frequency. You can use the same approach. setup a timer at the beginning then check it at the end of the block |
|
|
ferkar
Joined: 14 Jul 2007 Posts: 38
|
yes .. it looks very fine. |
Posted: Tue Mar 25, 2008 8:58 am |
|
|
i am going to try these techniques ..
thanks .... |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|