Nap and sleep commands


Results 1 to 16 of 16

Threaded View

  1. #13
    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 21:36. Reason: Postscript

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