SLEEP, WDT and INT


Closed Thread
Results 1 to 9 of 9
  1. #1
    xnihilo's Avatar
    xnihilo Guest

    Smile SLEEP, WDT and INT

    Hello,

    I would like to use the SLEEP command in my program.
    The main program is a small loop like:

    loop:
    Sleep 5
    GOTO loop

    Because when an interrupt occurs, program jumps at the INT handler and the stuff is processed there.

    My question is: I don't want to use WDT (which is a feature I don't understand anyway),
    can I use sleep without having to enable or disable registers related to WDT ?

    Thanks

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Nap might be more of what you want.
    From the manual
    NAP puts the processor to sleep for one Watchdog Timer period. If the
    Watchdog Timer is not enabled, the processor will sleep forever or until
    an enabled interrupt or reset is received
    Turn the WDT off in the config and the PIC should be in a low power mode until the interrupt occurs.
    Dave
    Always wear safety glasses while programming.

  3. #3
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default WDT and NAP

    From PBP pro manual:

    Places the microcontroller into low power mode for short periods of time. During this NAP, power consumption is reduced to minimum. The listed periods are only approximate because the timing is derived from the Watchdog Timer which is R/C driven and can vary greatly from chip to chip and over temperature. Since NAP uses the Watchdog Timer, its timing is independent of the oscillator frequency.

    It seems it needs WDT.
    Moreover, the right way to use this, according to PBP, it's to define a period.

    I don't want to use WDT and I don't want to set period. I would like to put the PIC into low power sleep until an int awakes it...

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Sure, just turn off the WDT in the configs.

    Then when you put it to sleep, it will stay that way until an interrupt is triggered.

    You can use ...
    Code:
    @  SLEEP
    and you won't need to enter a period.
    <br>
    DT

  5. #5
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Sure, just turn off the WDT in the configs.

    Then when you put it to sleep, it will stay that way until an interrupt is triggered.

    You can use ...
    Code:
    @  SLEEP
    and you won't need to enter a period.
    <br>
    Do I need to use
    @ sleep
    ?
    With PBP, can I use something like:

    loop:
    sleep
    goto loop

    ?

    (I always disable WDT in the config words).

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


    Did you find this post helpful? Yes | No

    Default

    Yes you can do something like that... but the assembler line @ sleep will send your PIC in sleep mode forever... or 'till an interrupt happen. PBP SLEEP will send your PIC in sleep mode for a x period of time and then wake up. It's really up to you. I prefer the @ SLEEP
    Steve

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

  7. #7
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by mister_e View Post
    Yes you can do something like that... but the assembler line @ sleep will send your PIC in sleep mode forever... or 'till an interrupt happen. PBP SLEEP will send your PIC in sleep mode for a x period of time and then wake up. It's really up to you. I prefer the @ SLEEP
    Thanks you all.

    So I can use something like:


    ON INTERRUPT GOTO myinthandler

    start:
    @ sleep


    myinthandler:
    ...

    In this case my main program is only the @sleep instruction and once the int has been processed, it goes back to sleep until next interrupt, is that right?

  8. #8
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Yes, that should work.
    This thread has some good info of the ins and outs
    http://www.picbasic.co.uk/forum/show...ighlight=sleep
    Read post #3
    Dave
    Always wear safety glasses while programming.

  9. #9
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks a lot!

Similar Threads

  1. Pin won't stay high during Repeat...Until loop??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th August 2009, 23:57
  2. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  3. Battery powered applications
    By NavMicroSystems in forum Off Topic
    Replies: 7
    Last Post: - 22nd June 2009, 07:12
  4. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  5. Wierd sleep issue
    By orca in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th March 2006, 22:06

Members who have read this thread : 0

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