-
Code execution time?
I remember seeing a post regarding how to measure the elapsed time for some code, but after searching for it I can't find it. My application is for a radio modem, and I need to measure things in the microsecond range. Any help either pointing me to that thread or code examples is appreciated!
Thanks!
Dave
-
-
One simple way is to assign an unused pin to an output then have it go HI just before the portion of code you need to measure then go LOW immediately afterwards. This output is now your code elapsed time o-scope test point!
Simple example:
Code:
Test VAR PORTB.2 ' Assign a name to the unused pin
Test=0 ' Set pin low at top of program
'Some of your program
Test=1 ' Set output HI
Your chunk of program here to be timed
Test=0 ' Set output LO
Rest of program continues from here
I use this alot and the cool thing about it is I can move it anywhere and have it trigger multiple times when looking timer activity. I'm sure there are slicker ways but this works for me.
-
This is one part of SteveB's implementation.
http://www.picbasic.co.uk/forum/showthread.php?t=365
Another version which also give you the codespace used and so on
http://www.picbasic.co.uk/forum/show...33&postcount=9
The whole story of the above
http://www.picbasic.co.uk/forum/show...9&postcount=13
If you have MPLAB, you could also use the StopWatch feature.
HTH