question about pollwait in latched state
basicstampede
Posts: 214
Below are two programs.· First goes to slot 0, and second goes to slot 1.
Question is listed below code.
' {$STAMP BS2p, pollwait2slot1}
' {$PBASIC 2.5}
sw0 PIN 0
led1 PIN 1
sw_reset PIN 2
idx VAR Byte
setup:
POLLIN 0, 0
POLLOUT 1, 1
POLLRUN 1
POLLMODE 12 'latched, pollout, pollwait, pollrun allowed
main:
·DEBUG "Slot 0:· ", CR ', DEC5 idx, CR
·POLLWAIT 7
GOTO main
' {$STAMP BS2p}
' {$PBASIC 2.5}
'This is program pollwait2slot1 which is in slot 1 of program above
DEBUG "Slot 1:· ", CR
DO WHILE IN2=1
LOOP
TOGGLE 1
POLLMODE 12
RUN 0
END
When I run the program above, it kind of works.· The problem is that since I've set POLLWAIT 7, BS2p wakes up every 2.3 seconds and checks the input switch.
If I press the pollin switch while BS2p is napping, it misses the "interrupt".· i.e. I must press and hold the pollin switch (pin 0) for at least 2.3 seconds to reliably have the Stamp respond.
Is there a way for Stamp to "latch" the switch input so that even if the switch was pressed while Stamp was napping, when it finally wakes up, it will see that the switch was pressed, and take program to slot 1 (in this case).·
Reason:· I want to maximize the napping time to save battery, but I don't want to miss the external trigger either.
Actually, I thought by putting it on POLLMODE 12, I was expecting the input switch to be latched, thus not miss this signal.· I guess Stamp really goes to sleep.
Any insights from anyone?
Thanks in advance.
Question is listed below code.
' {$STAMP BS2p, pollwait2slot1}
' {$PBASIC 2.5}
sw0 PIN 0
led1 PIN 1
sw_reset PIN 2
idx VAR Byte
setup:
POLLIN 0, 0
POLLOUT 1, 1
POLLRUN 1
POLLMODE 12 'latched, pollout, pollwait, pollrun allowed
main:
·DEBUG "Slot 0:· ", CR ', DEC5 idx, CR
·POLLWAIT 7
GOTO main
' {$STAMP BS2p}
' {$PBASIC 2.5}
'This is program pollwait2slot1 which is in slot 1 of program above
DEBUG "Slot 1:· ", CR
DO WHILE IN2=1
LOOP
TOGGLE 1
POLLMODE 12
RUN 0
END
When I run the program above, it kind of works.· The problem is that since I've set POLLWAIT 7, BS2p wakes up every 2.3 seconds and checks the input switch.
If I press the pollin switch while BS2p is napping, it misses the "interrupt".· i.e. I must press and hold the pollin switch (pin 0) for at least 2.3 seconds to reliably have the Stamp respond.
Is there a way for Stamp to "latch" the switch input so that even if the switch was pressed while Stamp was napping, when it finally wakes up, it will see that the switch was pressed, and take program to slot 1 (in this case).·
Reason:· I want to maximize the napping time to save battery, but I don't want to miss the external trigger either.
Actually, I thought by putting it on POLLMODE 12, I was expecting the input switch to be latched, thus not miss this signal.· I guess Stamp really goes to sleep.
Any insights from anyone?
Thanks in advance.
Comments
An aside: If you were using the BS2pe instead of the 'p, you could go to a much shorter POLLWAIT interval to catch the event without much penalty in current drain.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
input. I guess I have to put that capacitor. pe is also a good suggestion. Thanks.