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 CCS Technical Support

How to calculation duration or time in ms for a function

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



Joined: 18 Oct 2003
Posts: 145

View user's profile Send private message

How to calculation duration or time in ms for a function
PostPosted: Fri Sep 10, 2004 10:55 pm     Reply with quote

Hi,

I need to calculate the duration or time in ms for a function. This is for my technical documentation.

Is possible to send me the sample code for this???

Thank you very much!!!
cfernandez



Joined: 18 Oct 2003
Posts: 145

View user's profile Send private message

PostPosted: Fri Sep 10, 2004 11:01 pm     Reply with quote

Continue...

I am use a PIC18F8720 with a external clock the 25Mhz.

Thanks,
Ttelmah
Guest







Re: How to calculation duration or time in ms for a function
PostPosted: Sat Sep 11, 2004 2:04 am     Reply with quote

cfernandez wrote:
Hi,

I need to calculate the duration or time in ms for a function. This is for my technical documentation.

Is possible to send me the sample code for this???

Thank you very much!!!

Not really.
There are a number of ways of getting the time taken for a function. The easiest is to run it in a hardware or software simulator, add breakpoints either side, and record the program counter at these points. Alternatively, open the assembler file, and count the instructions used. If timing is critical though, you must be aware, that 'complex' functions (such as arithmetic), may well have slight variations in the times taken, according to the numbers used. In these cases, you'd have to go through the assembler, and make the 'worst case' assumptions at every branch, and then repeat this taking the 'best case' assumptions, to get two timing values, whic will 'bracket' the real time involved.
You need also to be aware that the optimiser will affect things, so you could sit down and calculate the times for individual lines of code, and yet find that a program using all these lines, takes less than the sum of these times, with the optimiser shortcutting some parts. This is why it is allways better to use one of the hardware timing components, if timing is 'critical'...

Best Wishes
kloppy



Joined: 28 Jul 2004
Posts: 32

View user's profile Send private message

PostPosted: Sat Sep 11, 2004 4:20 am     Reply with quote

you can also set a pin at the beginning of your function and clear it at the end.
then you can measure the duration with a scope.
to find out how long it takes to set a pin should be no problem.
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