Wake from sleep (Well, sorta) 16F88, PICBASIC PRO
I have written a program which puts the '88 in sleep mode, and it wakes up when the button attached to RB0/INT is pressed. No problem there.
However, I don't want the device to wake up if the button is pressed by accident. I want there to be a bit of code that, once the device wakes up, will test to see if the button has been held for two seconds, and then put it back to sleep if it hasn't.
I also use this button for other purposes.
Thanks in advance for your help.
Re: Wake from sleep (Well, sorta) 16F88, PICBASIC PRO
this will be done in your ISR... just check how many secondes the button is pressed since in the ISR, if more than 2 secondes, continue normal operation... case not return to sleep mode.
you need a While loop, a pause, a TimeOut/counter variable, maybe a IF-THEN and that's it... done.
Re: Wake from sleep (Well, sorta) 16F88, PICBASIC PRO
something around this
Code:
WHILE !_PB and (TimeOut<MaxTimeout)
PAUSE 100
Timeout=Timeout +100
WEND
IF Timeout<MaxTimeout THEN
' fail duties goes here
ELSE
' success duties goes here
ENDIF
Re: Wake from sleep (Well, sorta) 16F88, PICBASIC PRO
I'm assuming you haven't disable the WDT and if that's so, why not use NAP instead. You could set it to wake every two seconds and see if the button is pressed. I'd suggest though you set if for 1 second. With a setting of 2 second one might hold what they think would be too long and surmise the unit was inoperative.
Worked for me on a previouse project.