BASIC stamp manual v2.2

POLLWAIT – BASIC Stamp Command Reference
Page 336 BASIC Stamp Syntax and Reference Manual 2.2 www.parallax.com
polled-input pins. It "polls" these pins after the end of each PBASIC
command and before it reads the next PBASIC command from the user
program; giving the appearance that it is polling "in the background".
This feature should not be confused with the concept of interrupts, as the
BASIC Stamp does not support true interrupts.
The POLLWAIT command is unique among the polling commands in that
it actually causes execution to halt, until a polled-input pin event occurs.
The Duration argument is similar to that of the NAP command; using the
values 0 to 7 specifies the duration of the low-power period. After the
low-power period is over, the BASIC Stamp polls the polled-input pins
and determines if any meet the desired poll state. If no polled-input is in
the desired state (as set by POLLIN command) the BASIC Stamp goes
back into low-power mode, again, for the same duration as before. If any
polled-input is in the desired state, however, the BASIC Stamp will
continue execution with the next line of code.
A Duration of 8 makes the BASIC Stamp pause execution in normal
running mode (not low-power mode) until a polled-input event occurs.
The response time is indicated in Table 5.81 on page 335. Since the
response time is so fast, this feature can be used to synchronize a portion
of PBASIC code to an incoming pulse.
Duration Length of Low-Power Mode
0 18 ms
1 36 ms
2 72 ms
3 144 ms
4 288 ms
5 576 ms
6 1152 ms (1.152 seconds)
7 2304 ms (2.304 seconds)
8 No power-down
Table 5.82: Duration values and
associated low-power modes.
The following is a simple example of the POLLWAIT command.
POLLIN 0, 0
POLLMODE 2
Main:
POLLWAIT 2
TOGGLE 1
GOTO Main
A
SIMPLE POLLWAIT EXAMPLE.