Or outa & and outa
peterz
Posts: 59
Do these instructions affect only one pin ?
or outa, pin_mask
Does·set only PIN 1 ?
And:
and outa, pin_mask_off
Does clear only PIN 1 ?
Where masks are:
pin_mask LONG %0000_0000_0000_0000_0000_0000_0000_0010
pin_mask_off LONG %1111_1111_1111_1111_1111_1111_1111_1101
The problem I am having is that they seem to affect all other pins, not only the pins I am trying to set/clear.
Is this the right way to set/clear a pin under ASM ?
or outa, pin_mask
Does·set only PIN 1 ?
And:
and outa, pin_mask_off
Does clear only PIN 1 ?
Where masks are:
pin_mask LONG %0000_0000_0000_0000_0000_0000_0000_0010
pin_mask_off LONG %1111_1111_1111_1111_1111_1111_1111_1101
The problem I am having is that they seem to affect all other pins, not only the pins I am trying to set/clear.
Is this the right way to set/clear a pin under ASM ?
Comments
http://forums.parallax.com/showthread.php?p=601870
Brian
from what I can tell you are only working on 1 byte at a time , so have to declare that byte & then shift it over .
Brian
Example , this lights up 16 to 23 on demo board ( look at page 24 of the propeller manual)
PUB start
cognew(@entry, 0)
DAT
entry··· org
·········· ·mov·dira ,#$ff·······' in bin 0000_0000_0000_0000_0000_0000_1111_1111
··········· shl dira,#16··········' in bin·0000_0000_1111_1111_0000_0000_0000_0000
··········· mov·outa ,#$ff
··········· shl outa,#16
This does the same:
PUB start
··· cognew(@entry, 0)
DAT
entry········ org
············· mov···· t1,············ #$ff······· wz····· '···· Configure Pin
············· shl···· t1,············ Pin··················· ·'········· Create Mask with t1
············· muxnz·· outa,·········· t1················ ·'········· PreSet Pin HIGH········· "1"
············· muxnz·· dira,·········· t1·················· '········· Set Pin to an OUTPUT···· "1"
···························
Pin·········· long····· 16······························ · 'I/O Pin
t1··········· res······ 1································ · 'Pin Mask
Post Edited (Brian Beckius) : 2/11/2007 3:18:43 PM GMT
you can also handle set and clear bits with only one mask.