PDA

View Full Version : Create a label which point to an instruction



med2007
- 2nd October 2012, 15:11
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

Heckler
- 2nd October 2012, 15:41
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.

Acetronics2
- 2nd October 2012, 16:11
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 :rolleyes:

Alain

med2007
- 2nd October 2012, 17:53
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

Demon
- 2nd October 2012, 18:15
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

med2007
- 3rd October 2012, 08:33
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.

longpole001
- 3rd October 2012, 09:39
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



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

longpole001
- 3rd October 2012, 10:20
same code example as u wanted but without the comments is



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