Sleep & nap


Closed Thread
Results 1 to 25 of 25

Thread: Sleep & nap

Hybrid View

  1. #1

    Default Sleep & nap

    Hi!

    Using picbasicpro 2,50b and having
    DEFINE WDT_OFF ; one of the first statements
    and then later

    Both SLEEP 1
    and
    NAP 1
    hangs, get stucked, bog down

    Is the define wrong somehow or what do I miss here?
    Never used these commands before. Tried also
    @ DEVICE pic18F4550 WDT_OFF
    but that produced error 122.
    Tried some other things also but DEFINE WDT_OFF was the only one (I found) that compiled without errors.

    I'm missing something, but what?

    Thank's for all hints

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    From the manual
    Code:
    The Watchdog Timer is used in conjunction with the SLEEP and NAP
    instructions to wake the PICmicro MCU after a certain period of time.
    You need to enable the WDT. How about trying this
    @device 18F4550, WDT_ON

    I do not know if this will work as I've not checked

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


    Did you find this post helpful? Yes | No

    Default

    Also
    Code:
    @device 18F4550, WDT_ON
    is PM syntax.

    Must use MPASM for 18Fs
    Code:
    @ __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    A good late night read.
    http://www.picbasic.co.uk/forum/showthread.php?t=543
    Dave
    Always wear safety glasses while programming.

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Also
    Code:
    @device 18F4550, WDT_ON
    is PM syntax.

    Must use MPASM for 18Fs
    Code:
    @ __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    A good late night read.
    http://www.picbasic.co.uk/forum/showthread.php?t=543
    Thank you Dave and Jerson!

    Of course, it seems to me that I can't read
    That is also clearly written in the manual "...If the Watchdog Timer is not enabled, ther processor will sleep forever..., page 105", so I did not see the small word "not"...

    However, changing that to WDT_ON does not produce the wanted result.
    Added also WDTPS 128 but again without success.

    Is there something else involved here?

    That "543" is not solving this issue? It is showing that there can be many things that can go wrong... when you are not extremely familiar with this all...

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


    Did you find this post helpful? Yes | No

    Default

    there can be many things that can go wrong
    That is when the fun starts

    Can you post your whole code?
    The actual problem might be someplace else.
    Dave
    Always wear safety glasses while programming.

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    That is when the fun starts

    Can you post your whole code?
    The actual problem might be someplace else.
    Here, the fun has alredy started

    Code:
    DEFINE LOADER_USED 1
    DEFINE RESET_ORG 1000h      ' For Microchip USB Bootloader
    DEFINE INTERRUPT_ORG 1008h  ' For Microchip USB Bootloader
    define WDT_ON
    define WDTPS 128 
    
    DEFINE LCD_DREG       PORTD	' Set LCD Data port
    DEFINE LCD_DBIT       4		' Set starting Data bit (0 or 4 if 4-bit bus)
    DEFINE LCD_RSREG      PORTC	' Set LCD Register Select port
    DEFINE LCD_RSBIT      2		' Set LCD Register Select bit
    DEFINE LCD_EREG       PORTC	' Set LCD Enable port
    DEFINE LCD_EBIT       1		' Set LCD Enable bit
    DEFINE LCD_BITS       4		' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES      4		' Set number of lines on LCD
    DEFINE LCD_COMMANDUS  2000	' Set command delay time in us, 2000 us = 2ms
    DEFINE LCD_DATAUS     50	' Set data delay time in us, 50 us = 0,05ms
    
    powerOut     var PORTE.0
    onOffPressed var PORTD.2
    b var byte
    clear
    
    TRISE = %00001000   
    TRISC = %10110000   
    TRISD = %00001100
    powerOut = 1
       
    pause 1
    lcdout $FE, 1
    pause 1
    
    pstart:
      powerout = not onoffpressed
      lcdout $FE,2, "b=", dec b
      pause 100
      b = b + 1
      'nap 5
    goto pstart
    So, I can see b living with nap or sleep commented, but it hangs when not commented.

Similar Threads

  1. 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
  2. Battery powered applications
    By NavMicroSystems in forum Off Topic
    Replies: 7
    Last Post: - 22nd June 2009, 07:12
  3. 16F628A current high during sleep
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 9th October 2006, 10:21
  4. Wierd sleep issue
    By orca in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th March 2006, 22:06
  5. Replies: 5
    Last Post: - 5th February 2006, 16:51

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