POLLOUT - BASIC Stamp Command Reference
Page 228
•
BASIC Stamp Programming Manual 2.0b
•
www.parallaxinc.com
however, where the polled-output pins will latch the active state; they will
change only once (when the poll state is reached) and stay in the new state
until the PBASIC program tells it to change again. See the POLLMODE
description for more information.
A clever use of the "latched" feature is to set a polled-output to be the same
as the polled-input. For example, suppose an application needed to
respond in some way if a polled-input pin goes high, but it doesn't need to
respond immediately, and the other tasks should not be interrupted. In
essence, we need a way to know if the pin has gone high since the last time
we checked it. Look at this example:
POLLOUT 0, 1 'Set I/O 0 to polled-output, high
POLLIN 0, 1 'Set I/O 0 back to polled-input, high
POLLMODE 10 'Set mode to latch the polled-output
Idx VAR BYTE
Work: 'Do nonsense work, but check once in a
FOR Idx = 1 TO 20 'while to see if the polled event ever occured
DEBUG "Working…", CR
NEXT
IF OUT0 = 0 THEN Work
Respond: 'Send a different message if it did occur
DEBUG CR, "Hey! You set my pin high!", CR
POLLMODE 10 'Reset polled-output's latch function
GOTO Work
Here, we set I/O pin 0 to a polled-output, then immediately set it to a
polled-input. Then we set the polled-mode to latch the polled-outputs.
Since the POLLIN command occurred after the POLLOUT, I/O pin 0 will
be an input, but the polling feature will still affect the OUT0 bit (output
latch for I/O pin 0). Then, the program performs some work, and once in
a while, checks the state of OUT0. If OUT0 is 0, I/O pin 0 was never seen
to go high. If, however, OUT0 is 1, I/O pin 0 must have gone high while
the program was doing other work, and now it can respond in the proper
manner. This even works if the pin had gone high and then low again
before we check it (as long as it was high at some point in between the
instructions in our Work routine.
It is important to note that during the time between the POLLOUT and
POLLIN commands, I/O pin 0 will be set to an output direction. This can
cause a temporary short with the circuitry connected to I/O pin 0, so it is
A
CLEVER TRICK WITH
POLLOUT
AND THE
"L
ATCHED
"
FEATURE
.
Содержание BASIC Stamp 1
Страница 1: ...BASIC Stamp Programming Manual Version 2 0c...
Страница 30: ...Introduction to the BASIC Stamps Page 28 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 90: ...BUTTON BASIC Stamp Command Reference Page 88 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 118: ...END BASIC Stamp Command Reference Page 116 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 128: ...FREQOUT BASIC Stamp Command Reference Page 126 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 196: ...NAP BASIC Stamp Command Reference Page 194 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 206: ...OWIN BASIC Stamp Command Reference Page 204 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 214: ...OWOUT BASIC Stamp Command Reference Page 212 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 216: ...PAUSE BASIC Stamp Command Reference Page 214 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 226: ...POLLMODE BASIC Stamp Command Reference Page 224 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 232: ...POLLOUT BASIC Stamp Command Reference Page 230 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 236: ...POLLRUN BASIC Stamp Command Reference Page 234 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 240: ...POLLWAIT BASIC Stamp Command Reference Page 238 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 262: ...RCTIME BASIC Stamp Command Reference Page 260 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 274: ...RUN BASIC Stamp Command Reference Page 272 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 310: ...SEROUT BASIC Stamp Command Reference Page 308 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 324: ...STOP BASIC Stamp Command Reference Page 322 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Страница 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...