Propeller Manual

Table Of Contents
WAITPNE – Spin Language Reference
WAITPNE
Command: Pause a cog’s execution until I/O pin(s) do not match designated state(s).
((PUB PRI))
WAITPNE (State, Mask, Port )
State is the logic state(s) to compare the pins against. It is a 32-bit value that
indicates the high or low states of up to 32 I/O pins. State is compared against either
(
INA & Mask), or (INB & Mask), depending on Port.
Mask is the desired pin(s) to monitor. Mask is a 32-bit value that contains high (1)
bits for every I/O pin that should be monitored; low (0) bits indicate pins that should
be ignored. Mask is bitwised-ANDed with the 32-bit port’s input states and the
resulting value is compared against the entire State value.
Port is a 1-bit value indicating the I/O port to monitor; 0 = Port A, 1 = Port B. Only
Port A exists on current (P8X32A) Propeller chips.
Explanation
WAITPNE, “Wait for Pin(s) to Not Equal,” is one of four wait commands (WAITCNT, WAITPEQ,
WAITPNE, and WAITVID) used to pause execution of a cog until a condition is met. WAITPNE is
the complimentary form of
WAITPEQ; it pauses the cog until the value of Port’s I/O pin states,
bitwised-ANDed with Mask, does not match that of State.
When executed,
WAITPNE activates special “wait” hardware in the cog that prevents the
System Clock from causing further code execution within the cog until the moment the
designated pin, or group of pins, does not equal the designated state(s). The wait hardware
checks the I/O pins every System Clock cycle and the cog’s power consumption is reduced
by approximately 7/8
ths
during this time.
Using WAITPNE
WAITPNE is a great way to synchronize code to external events. For example:
waitpeq(%0100, %1100, 0) 'Wait for P3 & P2 to be low & high
waitpne(%0100, %1100, 0) 'Wait for P3 & P2 to not match prev. state
outa[0] := 1 'Set P0 high
The above code pauses the cog until P3 is low and P2 is high, then pauses the cog again until
one or both of those pins changes states, then it sets P0 high.
Page 224 · Propeller Manual v1.1