Chip speed


Closed Thread
Results 1 to 6 of 6

Thread: Chip speed

  1. #1
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697

    Default Chip speed

    Hi. Is it possible to find out how long it takes to run a certain block of code?

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


    Did you find this post helpful? Yes | No

    Default

    Yes indeed!

    at least 3 method
    1. use MPLAB sim or else simulator
    2. toggle a led and measure it with a scope
    3. use a PIC timer and show it on LCD or via SerialComm

    i like the Timer option as it measure the real stuff in a real environment. Have a look at the followings

    instruction execution time
    http://www.picbasic.co.uk/forum/showthread.php?t=365

    Now a collection of pretty nice and usefull tools...

    Example how to mix them all together...
    The Best Solution post #9
    http://www.picbasic.co.uk/forum/show...33&postcount=9

    The Best Solution --- The whole thread
    http://www.picbasic.co.uk/forum/show...ht=stuff+handy

    Once again... Thanks Darrel!
    Steve

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

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default

    Hi,
    You have a couple of options:
    ** Run it and time it in the simulator in MPLAB.
    ** Set a pin high when you enter the code section and low when you exit it. Look at the output with an oscilloscope.
    ** Use one of the PIC's timers to measure the execution time. Start it when you enter the section of code and stop it when you exit it. Someone (Darrel perhaps??) posted some code that was perfect for that but I can't seems to find it right now. I'll take another look.

    /Henrik Olsson.

    EDIT: OK Steve beat me to it. With nicer layout AND links to the code I was thinking about, and then some....
    Last edited by HenrikOlsson; - 21st November 2007 at 06:38.

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


    Did you find this post helpful? Yes | No

    Default

    even much funny, you said it in same order as me
    Steve

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

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Oh stop,

    You're making me blush.

    EDIT: What am I saying ??
    &nbsp; &nbsp; Bring it on.<br>
    Last edited by Darrel Taylor; - 21st November 2007 at 08:25. Reason: WooHoo.
    DT

  6. #6
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Wow. Thats a lot of stuff to be looking at. An oscilloscope is deffo out because i dont have one and i think they are expensive. Ive never used the simulator before but im guessing it runs on the PC and could be affected by other programs that are running. I will try out the timer method because it seems best. Ive just gotta have a good read through those links to find out how to use one.

    Thanx for the optimization bits too. I like things to be as optimized as possible.

Similar Threads

  1. USB Speed
    By Rony in forum USB
    Replies: 5
    Last Post: - 24th August 2008, 20:43
  2. USB Speed
    By Rony in forum General
    Replies: 0
    Last Post: - 21st August 2008, 22:15
  3. Closed loop speed controller
    By Ryan7777 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 26th January 2008, 14:15
  4. NEWB Help HPWM coding
    By Seafurymike in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 1st January 2008, 21:52
  5. Replies: 14
    Last Post: - 26th September 2007, 05:41

Members who have read this thread : 1

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