Code snippet: time execution for each line: help please


Closed Thread
Results 1 to 2 of 2
  1. #1
    xnihilo's Avatar
    xnihilo Guest

    Smile Code snippet: time execution for each line: help please

    Could someone be kind enough and tell me how many instruction cycles each line of this code will use because I need to know what time this routine takes to execute.
    I'm using a PIC16F684 and its internal oscillator at 8MHz

    Code:
    databyte = %00000000
    
    'wait for the header pulse to end and check if duration is about 2400us+/-100us
    j = 0
    WHILE (porta.0 == 0)
      PAUSEUS 20
      j = j + 1
    WEND
    IF (( j < 115) || (j > 125)) then abort    'wrong pulse duration
    
    FOR i = 0 to 7
    
    j = 0  
    WHILE (porta.0 == 1)    'wait until the bit prefix (600us no-pulse) ends
      PAUSEUS 20
      j = j + 1
    WEND
    IF ((j < 25) || (j > 35)) then abort    'wrong no-pulse duration, we want it to be 600us+/-100us
    
    j = 0
      WHILE (porta.0 == 0)
        PAUSEUS 20
        j = j + 1
      WEND
      IF ((j > 25) && (j < 35)) THEN
        databyte.0(i) = 0
        GOTO bypass
      ENDIF
      IF ((j > 55) && (j < 65)) THEN
        databyte.0(i) = 1
        GOTO bypass
      ENDIF 
    GOTO abort    'wrong pulse duration
    bypass:
    
    NEXT i
    
    abort:

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


    Did you find this post helpful? Yes | No

    Default

    There's few way to measure it
    a) Toggle a led between a code snip, and mesure it with a scope
    b) using MPLAB stopwatch
    c) using the following method
    http://www.picbasic.co.uk/forum/show...72&postcount=2

    and if you want to elaborate a bit more
    http://www.picbasic.co.uk/forum/show...33&postcount=9

    If you're using the above solution with Timer, don't forget to adjust your results with Timer ticks.
    Last edited by mister_e; - 6th April 2008 at 15:54.
    Steve

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

Similar Threads

  1. decoding quadrature encoders
    By ice in forum mel PIC BASIC Pro
    Replies: 93
    Last Post: - 28th February 2017, 09:02
  2. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  3. Timer in real time
    By martarse in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th July 2005, 14:24
  4. Line following robot... problems with some code
    By nepstar in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 24th March 2005, 01:10
  5. Time diference in microseconds
    By leonel in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 14th March 2005, 08:25

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