View Full Version : Or outa & and outa
02-11-2007, 06:43 PM
Do these instructions affect only one pin ?
or outa, pin_mask
Does·set only PIN 1 ?
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 ?
02-11-2007, 07:54 PM
check this out
02-11-2007, 08:56 PM
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 .
Example , this lights up 16 to 23 on demo board ( look at page 24 of the propeller manual)
·········· ·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:
··· cognew(@entry, 0)
············· 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.
or outa, pin_mask 'to set bit(s)
andn outa, pin_mask 'to clear bit(s)