|
|
View previous topic :: View next topic |
Author |
Message |
cfernandez
Joined: 18 Oct 2003 Posts: 145
|
How to calculation duration or time in ms for a function |
Posted: Fri Sep 10, 2004 10:55 pm |
|
|
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
|
|
Posted: Fri Sep 10, 2004 11:01 pm |
|
|
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 |
Posted: Sat Sep 11, 2004 2:04 am |
|
|
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
|
|
Posted: Sat Sep 11, 2004 4:20 am |
|
|
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. |
|
|
|
|
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
|