Shop OBEX P1 Docs P2 Docs Learn Events
Pin high , Pin low — Parallax Forums

Pin high , Pin low

anita1984anita1984 Posts: 23
edited 2008-12-02 18:45 in Propeller 1
Hello Forum , i have a motor , one of the pin ( when the pin is low the motor is on , when the pin is high the motor is off )
Is it's good to write like this :
DAT
              org                         
MotorOff  
              mov dira,Pin     
              mov outa,High    
MotorOn
              mov dira,Pin 
              mov outa,#0                 
                                                                                                                                                                                                            
Pin long|<7                           
High long $FFFFFFFF     




this will be in a code and i can call MotorOff or MotorOn , depends to my need
is this good method ?

Thank you Forum wink.gif
Anita

Comments

  • Erik FriesenErik Friesen Posts: 1,071
    edited 2008-12-01 22:45
    It has to be:

    or dira,Pin' this to set the pin output

    or outa,Pin' this sets it high

    andn outa,Pin' this sets it low

    Or, Paul Baker has another way he recommends that I can't remember right off.

    If you are setting these up as functions you have to have ret labels.
  • Andrew E MileskiAndrew E Mileski Posts: 77
    edited 2008-12-01 23:15
    Note that you can load:

    $0 through $1FF using "mov dest, #N"

    $FFFFFFFF through $FFFFFE01 ($-1 through $-1FF) using "neg dest, #-N"
  • anita1984anita1984 Posts: 23
    edited 2008-12-02 18:20
    Hello do you mean like this :
    DAT
                  org                         
    MotorOff      
                  or dira,Pin     
                  or outa,High   
    
    MotorOn
                  or dira,Pin 
                  andn outa,Pin                 
                                                                                                                        
                                                                                               
    Pin long|<7                         
    High long $FFFFFFFF
    
    



    Thank you in advance
    Anita
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-02 18:45
    You don't need "High" in your case.
        or      dira,PinMask   ' makes the pin an output
    
        andn  dira,PinMask   ' makes the pin an input
    
        or      outa,PinMask  ' make the pin high
    
        andn  outa,PinMask  ' make the pin low
    
    PinMask  long   |< Pin
    


    If the pin number is less than 9, you can use immediate operands
        or      dira,#|< Pin   ' makes the pin an output
    
        andn  dira,#|< Pin   ' makes the pin an input
    
        or      outa,#|< Pin  ' make the pin high
    
        andn  outa,#|< Pin  ' make the pin low
    
Sign In or Register to comment.