Sleep mode


Closed Thread
Results 1 to 6 of 6

Thread: Sleep mode

  1. #1
    Tomas's Avatar
    Tomas Guest

    Default Sleep mode

    Hi everybody!

    I want to put my '877 in SLEEP mode until i press a pushbutton which is connected to PORTB.0 and GND. I have looked at the the following example:
    http://www.melabs.com/resources/samples/x2/pbp/

    but when the switch is pressed the program restarts. I try to modify the code so that it can jump to a routine which i want the PIC to excute instead.
    How do i wake up the PIC when ONLY i press the button. Watchdog timer is OFF.
    Regards,
    Tom

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    I think your link is dud, however I assume you mean the wakex2.bas example.

    Don't use NAP but use the assembler @SLEEP in your PBP code in it's place instead. This will permanently cause the PIC to sleep until woken by an event. What 'events' will cause the PIC to wake is detailed in the 'Special Features of the CPU' section of your chosen PIC's Datasheet.

    There are lots of examples of this usage in past archives at the MeLabs site.

    http://list.picbasic.com/cgi-bin/board-search.cgi

  3. #3
    Tomas's Avatar
    Tomas Guest


    Did you find this post helpful? Yes | No

    Thumbs up Sleep mode

    Hi Melanie,
    It works now. I'm using @ SLEEP command. I tried to use this command before but didn't work. Now, i think by using @ DEVICE pic16F877, WDT_OFF, it is working. Thanks.


    At the moment i'm writing a Visual Basic program which displays the sent data from my '877. I have managed to send data using serout2, but i want to control the sent data before it is displayed. For example i want to press a Displaybutton to show the data.

    Before i was using event driven method in the VB program. Now i'm using polling, checking the receive buffer and when it has the data i want to display it. The display code listens to the Displaybutton. My problem is when i press the Displaybutton nothing displays. How does this polling method work?

    Regards,
    Tom

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Are we talking about POLLING here in terms of PBP or your VB program?

  5. #5
    Tomas's Avatar
    Tomas Guest


    Did you find this post helpful? Yes | No

    Default VB program

    VB program.

  6. #6
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    This isn't the right place to discuss VB code... but POLLING is a methodology equally applicable to any code (including PBP) where you continually check (poll) an I/O port, or a Flag, or a Register, or your Bank Account, or whatever, for a change to happen.

    This 'polling' is done in a loop. The loop can be a tight loop where you a looking for a change and acting on it immediately, or it can be a relatively loose loop, where you only check once in a while. The analogy here is if you're flat-broke, you check your bank account often so you can draw some cash out the instant your paycheck arrives. If you've ten-grand in the bank then you'll probably only check your bank account once a month when the statement falls through your letterbox. The frequency of polling (how often you do it over what length of time) is determined by your application (or desperation!). eg Capturing the picture of a bullet whizzing past your camera by polling a sensor on a port will require a far tighter loop than say polling for a push-button press on your toilet flush.

    VB example...

    Here is a boring and benign method of getting one character (an ASCII uppercase 'A') from the Keyboard...

    KeyboardLoop:
    A$=INPUT$(1)
    If A$<>"A" then goto KeyboardLoop

    Execution will stop at the above line until the user enters one character from the keyboard, only then will the program verify it's correct and proceed accordingly. This is NOT polling.

    Now here...

    KeyboardLoop:
    A$=INKEY$
    If A$<>"A" then goto KeyboardLoop

    ... we have the SAME RESULT, but this time using a 'polling' method. We are actually in an ACTIVE loop waiting for the event to happen. Execution is not suspended, but executes the loop continuously. Using the polling method, we can introduce other code into our active loop which will be executed whether the user presses the keyboard or goes off on holiday.

    Melanie

Similar Threads

  1. High Power Consumption in Sleep Mode
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 18th September 2014, 14:29
  2. Replies: 4
    Last Post: - 9th October 2009, 09:01
  3. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 10:00
  4. Need help with SLEEP mode
    By aggie007 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 28th November 2007, 10:56
  5. Replies: 3
    Last Post: - 27th November 2007, 09:56

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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