Wake from sleep (Well, sorta) 16F88, PICBASIC PRO


+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2011
    Posts
    4

    Default 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.

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default 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.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default 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
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default 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.

Similar Threads

  1. Replies: 13
    Last Post: - 30th July 2012, 21:11
  2. 16F690... How to wake from sleep?
    By Heckler in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 5th July 2011, 22:07
  3. 16F181: can't wake up from sleep
    By Navaidstech in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 9th January 2010, 04:33
  4. wake up from sleep
    By savnik in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 31st August 2007, 17:09
  5. ? about sleep/wake on pin change and WDT
    By kessral in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 25th January 2007, 23:25

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts