Code execution time?


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2009
    Location
    Huntsville, AL
    Posts
    36

    Default 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

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

  3. #3
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default

    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.
    Louie

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  2. Serin2 - All I Need Is 8 Numbers....
    By SOMRU in forum Serial
    Replies: 4
    Last Post: - 14th December 2006, 13:50
  3. How to calculate machine time in basic code?
    By chai98a in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 23rd February 2006, 23:44
  4. Command execution time
    By barkerben in forum General
    Replies: 2
    Last Post: - 7th December 2004, 20:29
  5. instruction execution time
    By tjg in forum Code Examples
    Replies: 3
    Last Post: - 21st April 2004, 18:15

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts