Ok thank you, the problem i am facing now is that i am unable to only run that particular function once. Its keeps on running and starts opening library files.
Ok thank you, the problem i am facing now is that i am unable to only run that particular function once. Its keeps on running and starts opening library files.
Only do Assembler, but you should be able to use Breakpoints in your code, simply move the pointer to the first line of the delay code and right click and select a breakpoint.
Do the same but on the line of code after the delay routine - that defines the timing period for the stopwatch.
In Sim press F9 to get to the first breakpoint, reset the stopwatch, ensuring you have also selected the correct osc frequency, press F9 again at it will then do the delay routine and stop on its exit so you can see the actual time on the stopwatch.
Thank you Wp100, that works. One problem now is that how can i give a variable some value which is not to be included into the stopwatch time. For example, i have a loop which runs 't' times, how can i set the value of 't' for debugging.
If the setting the variable is part of the delay routine why exclude it ?
Setting that variable before your first breakpoint is the way to do it in Assembler but no idea how you do that in C - sure others can help though......
C18 compiler from microchip has Delays library which provides delay in terms of clock cycles. They are not actually calibrated in terms of divisions of seconds.
So what, then just write an ultra basic routine that does the math to convert from the number of clock cycles to real world time based on the current chip speed.
The C18 delay routines provide a delay that is fixed at compile time. No variable delay is available and so the above is quite useful. Note, the above actually uses the fixed C18 delays.
There's no wrapper or additional library code out there? I find that odd. I'm just starting to use AVR GCC for my AVR's and even stock off a fresh compile it comes with routines to provide us or ms delays.
In C18 its not like that The above code which Pommie sent will only work for 4MHz frequency. Hence if frequency is changed, will need to change the delay function little bit.
In other C compilers like BoostC and MicroC these functions are pre made.
I actually want to move to AVR soon after i am done with a simple project which requires TCP/IP Stack free from microchip