CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

how could i measure the total time for executing the code?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ferkar



Joined: 14 Jul 2007
Posts: 38

View user's profile Send private message

how could i measure the total time for executing the code?
PostPosted: Mon Mar 24, 2008 9:28 am     Reply with quote

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







PostPosted: Mon Mar 24, 2008 10:09 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Mar 24, 2008 11:42 am     Reply with quote

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 Wink
ferkar



Joined: 14 Jul 2007
Posts: 38

View user's profile Send private message

yes .. it looks very fine.
PostPosted: Tue Mar 25, 2008 8:58 am     Reply with quote

i am going to try these techniques ..

thanks ....
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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