Shop OBEX P1 Docs P2 Docs Learn Events
Or outa & and outa — Parallax Forums

Or outa & and outa

peterzpeterz Posts: 59
edited 2007-02-11 19:20 in Propeller 1
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 ?

Comments

  • Brian_BBrian_B Posts: 842
    edited 2007-02-11 12:54
  • Brian_BBrian_B Posts: 842
    edited 2007-02-11 13:56
    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
  • KaioKaio Posts: 265
    edited 2007-02-11 19:20
    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)
    
    
Sign In or Register to comment.