Shop OBEX P1 Docs P2 Docs Learn Events
waitpne in PASM — Parallax Forums

waitpne in PASM

mirrormirror Posts: 322
edited 2007-06-18 16:48 in Propeller 1
I don't know if anybody else has found this, but waitpne possibly needs some more instruction in the user manual for assembly. If I do:
ScanInputs
                    waitpne LastIn,MaskIn       'Wait for a pin change
                    mov     LastIn,INA          'Get the pins
                    .
                    wrlong  foo, bar            'Tell spin about change
                    .
                    jmp #ScanInputs
 
LastIn              long 0
MaskIn              long $00_00_ff_00


Then it just goes round and round as fast as possible. The waitpne doesn't seem to stop execution at all. But if I do:
ScanInputs
                    waitpne LastIn,MaskIn       'Wait for a pin change
                    mov     LastIn,INA          'Get the pins
                    and     LastIn,MaskIn       'Mask out unwanteds
                    .
                    wrlong  foo, bar            'Tell spin about change
                    .
                    jmp #ScanInputs
 
LastIn              long 0
MaskIn              long $00_00_ff_00


The all is good, and waitpne behaves as expected. (The extra and instruction is the only change - honest).

Am I missing something, or have others found the same thing?




▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It's not all that hard to count the number of grains of sand on the beach. The hardest part is making a start - after that it just takes time.·· Mirror - 15 May 2007

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-06-18 15:54
    The Propeller manual is a reference manual, not a tutorial, so sometimes its explanations and descriptions are short, but complete. The descriptions of the WAITPNE/PEQ instructions do say that the input pin values are masked with the source operand, then compared with the destination operand (the "state"). That would imply that your second code fragment is the one that would work and your first code fragment will only work if all the other I/O pins are zero.

    There's nothing wrong with the description in the manual, but something like your second code fragment could be a useful example of a common task in the "Assembly Code Examples for the Beginner" thread. If you do post it there, it would need a little more in the way of comments about what you're trying to do.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-06-18 16:48
    This is because of the way the logic for the instruction is constructed, if any bit in LastIn is set but not set in MaskIn it will immediately fall through. Similarly for waitpeq, if any bit in the Value is set but not set in the Mask, the instruction will hang.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
Sign In or Register to comment.