Shop OBEX P1 Docs P2 Docs Learn Events
simple PASM hanging on Waitpne and waitpeq — Parallax Forums

simple PASM hanging on Waitpne and waitpeq

RS_JimRS_Jim Posts: 1,765
edited 2015-02-12 20:24 in Propeller 1
Hi,
I am trying to run multiple pings in PASM in a single cog.
When I comment out the waitpne,waitpeq, the program loops through and enables each ping in turn. When I remove the comments, it pulses the first ping and then hangs.
help
Jim

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2015-02-12 01:38
    RS_Jim wrote: »
    When I comment out the waitpne,waitpeq, the program loops through and enables each ping in turn. When I remove the comments, it pulses the first ping and then hangs.
    You do specify the destination register (comparison value) as 0. That - however - is only its address not its value (which is mov t1, par). You could remove the null constant and re-enable the cog register (rename :null to null) or simply change the null constant to $1F0 (shadow[par], which is unused and defaults to zero).
  • RS_JimRS_Jim Posts: 1,765
    edited 2015-02-12 05:50
    Ok, I'll try that. I have tried to to do waitpne #0,pinmask but the compiler complains that I need a constant, variable, etc.
    Thanks,
    Jim
  • tonyp12tonyp12 Posts: 1,951
    edited 2015-02-12 06:13
    WAITPxx State,Mask
    Mask (s-field) bitwise ANDed with INA before the comparison with State (d-field).

    You can never use a # on the left side and you should try to avoid # on the right side too as that would limit you to the first 9pins and makes it harder to change code later.

    Using WAITPxx with a single pin is very easy:
    WAITPEQ mypin,mypin   'wait for it to be high
    WAITPNE mypin,mypin   'wait for it to be low
    mypin long |<12       'P12
    


    How to wait for 2pins either one is low:
    WAITPNE mytwopins,mytwopins   'wait for either one (or both) to be low 
    mytwopins long |<12 | |<13    'the two pins ORed
    

    How to wait for 2pins where one is low and one is high:
    WAITPEQ mypinstate,mytwopins  'wait for a match 
    mytwopins  long |<12 | |<13   'the two pins ORed
    mypinstate long |<12          'pin12 needs be high and pin 13 needs to be low
    

    How to wait for 2pins where either one is high
    WAITPNE myzero,mytwopins    'wait for either one to be high 
    mytwopins long |<12 | |<13  'the two pins ORed
    myzero    long 0            'you could use PAR,INA,CNT etc shadow register as they default to zero but lets not
    
  • Mark_TMark_T Posts: 1,981
    edited 2015-02-12 10:35
    I'd use a busy-wait loop that tests the relevant pin or pins and also checks for a timeout....

    Since you've 60us to wait pr cm of distance for a sonar sensor the reduced granularity of
    elapsed time by using an ASM loop rather than waitpne is not an issue as 60us is 1200
    instructions...
  • RS_JimRS_Jim Posts: 1,765
    edited 2015-02-12 20:24
    Hi guys, thanks for the replies. I replaced the null with a long named zero and set to zero. That solved my waitpeq/pne problem. Now to getting the math working in the spin part of the program.
    Jim
Sign In or Register to comment.