Create a label which point to an instruction


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2008
    Location
    lincoln uk
    Posts
    20

    Default Create a label which point to an instruction

    How do I create a short cut to an instruction in PBP such as

    H9 means or points to instruction like HIGH PORTB.0 ?

    So instead of writing HIGH PORTB.0: PAUSE 10 : LOW PORTB.0

    I can write H9: PAUSE 10: H9 ??

    Cheers
    Michael

  2. #2
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: Create a label which point to an instruction

    You can create aliases to port.pins like this...

    H9 var PORTB.0

    Then you can do this...

    MAIN:
    HIGH H9: PAUSE 100: LOW H9: PAUSE 100
    GOTO MAIN

    This is detailed in the PBP manual, section 4

    I am not aware of a way to do a macro that will execute several commands... someone else may know a way.
    Last edited by Heckler; - 2nd October 2012 at 15:45.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default Re: Create a label which point to an instruction

    Quote Originally Posted by med2007 View Post
    How do I create a short cut to an instruction in PBP such as

    H9 means or points to instruction like HIGH PORTB.0 ?

    So instead of writing HIGH PORTB.0: PAUSE 10 : LOW PORTB.0

    I can write H9: PAUSE 10: H9 ??

    Cheers
    Michael
    your idea is somewhat complicated ... till PBP already does it !!!

    PULSOUT PortB.0, 100 ' 100 @ 4Mhz or 500 @ 20Mhz
    or
    H9 var PORTB.0 ' in the header
    ...
    PULSOUT H9,100 ' 100 @ 4Mhz or 500 @ 20Mhz


    soo simple, when opening the Holy manual

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Jan 2008
    Location
    lincoln uk
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Create a label which point to an instruction

    Thanks for the insight, however I want to say...
    H9 : pause 10 ...... not HIGH H9 pause 10 .... and achieve same result
    I want H9 to mean HIGH PORTB.0
    I am old and frail and need help.
    Michael

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,154


    Did you find this post helpful? Yes | No

    Default Re: Create a label which point to an instruction

    I'm curious why the GOSUB command does not suit your needs.

    Do you want to substitute just that one command? If so, you are creating a lot of overhead for something really small.

    If it's because you want to keep things extra simple in your code, what about clear comments? My memory is no longer what it used to be so I include a LOT of comments in my code. Comments do nothing to your program; they take no space and do not affect performance.

    Robert

  6. #6
    Join Date
    Jan 2008
    Location
    lincoln uk
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Re: Create a label which point to an instruction

    I am frail, old and grey and have lost my book.

    Here it is again; I think I have not formed the question correctly.

    I want to convert:

    main:
    HIGH PORTB.0 : PAUSE 10 : LOW PORTB.0 : PAUSE 10
    GOTO main

    to

    main:
    H9 : PAUSE 10 : LOW H9 : PAUSE 10
    GOTO main

    ?? Can I precede the code with H9 VAR HIGH PORTB.0 ??

    Michael
    I am frail, old and grey and have lost my book.
    It has temporarily disappeared into a QBH, Quantum Black Hole, which I find abound in my locality.

  7. #7
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: Create a label which point to an instruction

    not sure if this what you want but if i am reading this correctly the code might be the following ,

    Assumptions that is taken for the following example code are

    1.digital ports have been set in config not analog
    2. the OSC type is defined in config correct value , assumed to be 8Mhz in example ,
    3. the port is setup for output in config eg TRISB = %00111100
    4. the port used is able to be output not input only
    5. correct setting of week pullups is set
    6. the output pulse is expected to be a digital output not varable analog
    7. other external ccts not effect current drain on output etc
    8, that other code required in pic will not stop the loop

    This code only creates a square wave pulse of 10Ms high and 10ms low during its continued execution ,and thats fine as long as thats all its going to do and no other program needs to be called else it will stop

    to make it clearer and to get what you end up wanting it would help if you advised the chip type ,and associated ccts and what the end goal is

    but given these assumptions above

    Code:
      DEFINE OSC 8             ' Timing referance for pause , pauseus commands
     H9 var PORTB.0            ' Port B.0 is output pin digital TTL 
    
    H9 = 0                           ' Set output to low on startup
    
    Main:
    H9 =1             ' Set output to high 
    pause 10         ' allow it to be high for 10ms 
    H9=0              ' set output to low 
    pause 10        ' allow pulse low for 10ms
    goto main
    regards

    Sheldon

  8. #8
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: Create a label which point to an instruction

    same code example as u wanted but without the comments is

    Code:
     DEFINE OSC 8             ' Timing referance for pause , pauseus commands
     H9 var PORTB.0            ' Port B.0 is output pin digital TTL 
    
    H9 = 0                           ' Set output to low on startup can remove and assume it 0 to start but hey
    Main:
    H9 =1   :pause 10 :H9=0: pause 10
    goto main

Similar Threads

  1. Replies: 5
    Last Post: - 12th September 2011, 08:51
  2. I wish to create an article for the WIKI
    By Normnet in forum Forum Requests
    Replies: 2
    Last Post: - 5th January 2011, 04:12
  3. How do you create a lookup table?
    By AlexanderWinnig in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 12th November 2010, 14:37
  4. pic16f88, xbee's & point-2-point comms
    By rdxbam in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd February 2009, 08:43
  5. How to create multidimensional Array
    By jiunn82 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th February 2007, 18:23

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