Watchdog periodic wakeup


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2009
    Location
    South Wales (UK)
    Posts
    62

    Default Watchdog periodic wakeup

    Hi all,

    The solution to this is probably very straightforward but I'm trying to use the watchdog as a wakeup timer based on the roughly 4ms 'no postscaler (=1)' setting...

    The inc file is as follows:

    Code:
    NOLIST
     ifdef PM_USED
     LIST
     "Error: PM does not support this device. Use MPASM."
     NOLIST
     else
     LIST
     LIST p = 18F26J53, r = dec, w = -311, f = inhx32
     INCLUDE "P18F26J53.INC" ; MPASM Header
     CONFIG XINST = OFF
     CONFIG PLLDIV = 2; 
     CONFIG WDTPS = 16;
     CONFIG WDTEN = ON
     CONFIG OSC = HSPLL; INTOSCPLL 
    CONFIG ADCSEL = BIT12
     CONFIG RTCOSC = T1OSCREF 
    CONFIG IESO = OFF
     CONFIG CFGPLLEN = ON
     CONFIG CPUDIV = OSC1
     CONFIG CLKOEC = OFF
     CONFIG SOSCSEL = LOW
     CONFIG DSBOREN = OFF
     NOLIST
     endif
     LIST
     BLOCK_SIZE EQU 64
    ...whilst the PBP program is:


    Code:
    Include "modedefs.bas"
    
    DEFINE OSC 24                                         
    
    ancon0 = %11111111
    ancon1 = %00011111
    
    intcon = 0
    intcon2 = %11110101
    intcon3 = %00000000
    
    blue_led                var portb.2
    red_led                 var portb.1
    
    ADCON0.0                =   0
    ADCON1                  =   15
    
    trisa                   =   %00000000
    trisb                   =   %10100000
    trisc                   =   %00000000
    
    pmdis0 = %11111101
    pmdis1 = %11111101
    pmdis2 = %11111111
    pmdis3 = %11111111
    WDTCON.0 = 1
    
    main:
    high red_led
    low blue_led
    sleep 5
    @ nop
    high blue_led
    low red_led
    sleep 5
    @ nop
    goto main
    Essentially, I just want the board to go to sleep minimising current but wakeup every 4 ms or so, switch and LED, or do something, and go back to sleep.

    But... the LED switching frequency seems to be a function of the SLEEP value as opposed to the WDT postscaler value. I assumed that once the device was asleep, that was it fo rthe SLEEP command and when it woke up, it was past that, through the NOP command and onto the next line of code... and hence the value of the SLEEP command was meaningless....
    i.e. if I set the sleep values to SLEEP 1, the LED switching frequency is far quicker than for SLEEP 5...

    Please help...

    Regards

    Jimbo

  2. #2
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: Watchdog periodic wakeup

    Use @ SLEEP
    PBP SLEEP will override your wdt settings.

  3. #3
    Join Date
    Sep 2009
    Location
    South Wales (UK)
    Posts
    62


    Did you find this post helpful? Yes | No

    Default Re: Watchdog periodic wakeup

    ARGHHHHHHHHHHHHH it was THAT simple?!

    ok, now I'm smiling!

    Many thanks... I think that answers other questions that have been bubbling away in the back of my mind with other projects!

    And thank you for being so quick! I literally went to make a coffee, returned and refreshed and there it was.

  4. #4
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: Watchdog periodic wakeup

    Glad I could help.

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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