PBP instruction clock cycles


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219

    Default PBP instruction clock cycles

    Would someone please give me your best guess for the number of clock cycles from the first Port read to and including the second Port read of the following instructions. I am trying to checking an input for a hall effect sensor looking at a rotating notched disk and would like to know the time between input reads as to make needed adjustments. I have never seen a list of PBP instruction clock cycles for simple instructions.
    Thanks: Mountain

    IF PortC.4=1 THEN
    Avar=1
    Else Avar=0
    Endif

    IF PortC.4=1

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


    Did you find this post helpful? Yes | No

    Default

    Guessing not required.
    You can measure it.

    instruction execution time
    http://www.picbasic.co.uk/forum/show...72&postcount=2
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Oh, forgot to mention ...

    Changing

    IF PortC.4=1 THEN

    -- to --

    IF PortC.4 THEN

    will reduce it considerably.

    With IF PortC.4=1, it places the value of the BIT in a temporary WORD sized variable, then calls a PBP library function that compares the whole word.

    With IF PortC.4, it's 2 instructions (btfss/goto).
    This only works with BIT vars.
    <br>
    DT

  4. #4
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default

    Thanks Darrel, that’s great. What is the effect of the underbar preceding picOSC in line one? I looked through the PBP manual but didn't see anything about an underbar. Did I miss it? I'll save your post link for future reference. Thanks again!
    Mountain

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


    Did you find this post helpful? Yes | No

    Default

    In assembly, there are a lot of names already used, many of them are even single letters. Since you can't reuse variable names that are already in use, PBP places an underscore in front of all variables declared in your program to eliminate possible contentions.

    While working in PBP those underscores are transparent, because PBP adds them when needed. But at the ASM level, you have to add the underscore to the PBP variable name to be able to access it.

    In the case of _PicOSC, it just retrieves the value of the DEFINE OSC XX for use in calculating the amount of time used by the statements.
    The OSC value is not directly available in PBP.

    Did I miss it?
    Section 8.2 Programming in Assembly Language
    Page 180 in the latest manual.

    hth,
    DT

Similar Threads

  1. Reading variables - more clock cycles?
    By kevj in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 23rd February 2008, 19:53
  2. instruction cycles for math operations
    By Michael Wakileh in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th July 2007, 11:03
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  4. code size using On Interrupt PBP instruction
    By eduardojx in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st December 2005, 09:57
  5. How to set external clock source in PBP
    By TurboLS in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 19th February 2005, 15:56

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