Shop OBEX P1 Docs P2 Docs Learn Events
PASM single pin turn on or off. — Parallax Forums

PASM single pin turn on or off.

TJHJTJHJ Posts: 243
edited 2008-09-26 13:46 in Propeller 1
I dont know why I am having such a hard time with this. I am new to PASM( In case you missed that LOL). And I cant seem to find an example.

So I cant seem to figure out how to turn on or off a single pin. If I use the mov command, I overwrite the whole register. If I use an or command I cant garentee which state it is in.

Anyone have an example of how to do this.

Thank you for your time.

TJ

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-09-26 03:58
    To turn on a pin (set it to 1), use OR. To turn off a pin (set it to 0), use ANDN. They can both use the same bitmask. For example:
                   OR      OUTA,bitmask   ' This turns the pin on
    
                   ANDN OUTA,bitmask   ' This turns the pin off
    
    bitmask   LONG   |< 16              ' Have a single bit turned on (1).  The rest are zeroes.
    


    The above assumes that the corresponding bit in DIRA has been turned on already.
  • TJHJTJHJ Posts: 243
    edited 2008-09-26 05:08
    Thanks mike, I was trying way to hard at this

    TJ
  • StefanL38StefanL38 Posts: 2,292
    edited 2008-09-26 13:46
    Hello TJ,

    take a look at the PASM-commands MUXC MUCNC MUXZ MUXNZ Prop-manual page 383ff.

    short example:
                  mov       _dummylong, #0 wz               'load zero-value => Z-Flag=1
                  muxz      DirA, _Bit                      'set the bit 
    
    
    'define a constant at the bottom of the PASM-code 
    _Bit              long |< 22 'create Bitmask where only bit 22 is set
    
    



    best regards

    Stefan
Sign In or Register to comment.