PDA

View Full Version : Or outa & and outa



peterz
02-11-2007, 07:43 PM
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 ?

Brian_B
02-11-2007, 08:54 PM
check this out
http://forums.parallax.com/showthread.php?p=601870


Brian

Brian_B
02-11-2007, 09:56 PM
Peter,
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

Kaio
02-12-2007, 03:20 AM
Peter,

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)