Nap and sleep commands


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Jun 2005
    Location
    Surrey, England
    Posts
    35


    Did you find this post helpful? Yes | No

    Default

    Since our production circuit board has been professionally produced, there is not room for an extra Xtal and caps to drive TMR1 so I am trying to get the WDT to do the wake from sleep but with only partial success. In particular it doesnt seem to matter what I put as a postscaler value the WDT seems to cycle at a fixed period of around 578 mSec (suspiciously similar to Nap 5 frequency!). I am setting CONFIG2H by using this instead of the corresponding (commented out) line in 18F4550.INC:
    Code:
    asm
           __CONFIG    _CONFIG2H, _WDT_OFF_2H & _WDTPS_256_2H
    ;must comment out in 18F4550.INC, or change there, else duplicate error
    endasm
    and then:
    Code:
                i = 0
    lowpower:   lcdout $FE, $02, "WDT ", hex2 i, 
                i = i + 1
                ' Do all the other stuff here (read ADC, store to Mem) 
                clearwdt
                WDTCON = 1       'SWDTEN
    '           OSCCON.7 = 0     'Clear IDLEN - switch to SLEEP 
                OSCCON.7 = 1     'Set IDLEN - switch to SEC_IDLE
    @           SLEEP 
    @           NOP  
                WDTCON = 0    ' WDT off
                goto lowpower
    and i increments 128 in 74 secs (period = 578mSec), but different values of _WDTPS_1024_2H etc. make no difference. What am I missing here? It makes no difference whether I make the CPU sleep or idle (except to the current consumption 3 or 15 mA - most of the 3 lost in the 9v voltage regulator).
    DEFINE NO_CLRWDT 1 makes no difference and the CLEARWDT also seems to make no difference!

    I would like to have the ability to control the frequency as expected and am thinking I can sleep for most of the 1 second I want and fine tune with another timer while awake - PAUSE would be the simplest. Any ideas gratefully received!

    Peter

    PS It just occurs to me that I am using a Bootloader - could this mean that the Postscaler is set by the bootloader and not changed by my program - if so can I do anything to change this ??edit the bootloader somehow.
    Last edited by FinchPJ; - 25th August 2010 at 22:36. Reason: Postscript

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


    Did you find this post helpful? Yes | No

    Default

    Most bootloaders will not allow you to change config settings, but the Microchip USB loader will, or you can change WDT config settings at runtime.

    See these threads:

    http://www.picbasic.co.uk/forum/showthread.php?t=4093

    http://www.picbasic.co.uk/forum/show...ghlight=config

    Or just open the loader .HEX file, make your changes, save it, and reprogram the PIC with the new loader firmware.
    Last edited by Bruce; - 26th August 2010 at 20:09.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Jun 2005
    Location
    Surrey, England
    Posts
    35


    Did you find this post helpful? Yes | No

    Default

    Now that is seriously helpful - Sorry I didnt spot those earlier on my searches - thank you so much for your help Bruce (and Darrel) - you are amazing!

    Peter

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