16f883 sleeping mode


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2013
    Posts
    8

    Red face 16f883 sleeping mode

    Hi! How can I minimize the currentdraw in sleep mode with a 16f883? I 've disabled most of the peripherals. I use 4 MHz internal oscillator and disabled the watchdog . But in sleep currentdraw still high level(450 µA) . My goal is <5 µA is this possible and how.

    Codes:

    ANSEL=%00000000'all analogue ports to digital
    ANSELH=%00000000'all analogue ports to digital
    ADCON0.0=0'disable ADC
    CM1CON0=%00000000'disable COMPARATOR 1
    CM2CON0=%00000000'disable COMPARATOR 2
    SSPCON=%00000000'disable SERIAL PORT
    RCSTA=%00000000'disable SERIAL PORT
    PCON=%00000000'disable BOR and ULPW
    OPTION_REG=%00000000'disable INTERNAL PULLUPS
    WPUB=%00000000'disable INDIVIDUAL PULLUPS
    IOCB=%00000000'disable INTERRUPT ON CHANGE
    CCP1CON=%00000000'disable ECCP1
    PSTRCON=%00000000'disable PULSE STEERING MODE
    T1CON=%00000000'disable TIMER1

    TRISB=%11111111
    TRISC=%00000000
    TRISA=%00000000
    porta=0
    portc=0


    SYMBOL BUTON0=PORTB.0
    SYMBOL BUTON1=PORTB.1
    SYMBOL BUTON3=PORTB.3
    SYMBOL BUTON4=PORTB.4
    SYMBOL BUTON5=PORTB.5
    SYMBOL BUTON6=PORTB.6


    main:
    IF BUTON0=0 then portc.1=1
    IF BUTON1=0 then portc.2=1
    IF BUTON3=0 then portc.3=1
    IF BUTON4=0 then portc.4=1
    IF BUTON5=0 then portc.5=1
    IF BUTON6=0 then portc.6=1
    PORTC=%00000000
    GOTO main

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


    Did you find this post helpful? Yes | No

    Default Re: 16f883 sleeping mode

    SLEEP

    SLEEP Period

    Place microcontroller into low power mode for Period seconds. Period is 16-bits, so delays can be up to 65,535 seconds (just over 18 hours).

    SLEEP uses the Watchdog Timer so it is independent of the actual oscillator frequency. The granularity is about 2.3 seconds and may vary based on device specifics and temperature. This variance is unlike the BASIC Stamp. The change was necessitated because when the PICmicro executes a Watchdog Timer reset, it resets many of the internal registers to predefined values. These values may differ greatly from what your program may expect. By running the SLEEP command uncalibrated, this issue is sidestepped.

    SLEEP 60 ' Sleep for about 1 minute
    The above is from the manual. I post it as I do not see the "SLEEP" command in your code.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Feb 2013
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: 16f883 sleeping mode

    I don't know how to write code to sleep. I want help for it.
    Quote Originally Posted by mackrackit View Post
    The above is from the manual. I post it as I do not see the "SLEEP" command in your code.

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


    Did you find this post helpful? Yes | No

    Default Re: 16f883 sleeping mode

    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jan 2012
    Location
    Grid EN19MV
    Posts
    159


    Did you find this post helpful? Yes | No

    Default Re: 16f883 sleeping mode

    Here's some code from when I needed a 16f886 to sleep until PORTB.0 went low. You should be able to adapt it. I should mention that I am self-taught at BASIC so there's probably a better way to do this:


    Code:
    #CONFIG __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _LVP_OFF & _CP_OFF
    
    #ENDCONFIG
    
    DEFINE NO_CLEARWDT 1 'NO WATCHDOG TIMER
    DEFINE OSC 8  'LETS PBP KNOW THE OSCILLATOR IS RUNNING AT 8MHz
    
    OSCCON = %01110001 '8 MHz INTERNAL OSCILLATOR, INTERNAL OSCILLATOR IS USED FOR SYSTEM CLOCK
    
    DISABLE 'NO INTERRUPTS, NO DEBUG COMMENT THIS OUT FOR INTERRUPTS
    
    
    ANSEL = 0 'PORTA ALL DIGITAL
    ANSELH = 0 'PORTB ALL DIGITAL
    
    OPTION_REG = 0 'PORT B PULLUPS ENABLED
    WPUB = %01111111 'PULL UPS ENABLED ON PORTB 0-6
    
    INTCON = 0 'INTERRUPTS DISABLED
    IOCB = %00000001 'PORTB.0 INTERRUPT ON CHANGE ENABLED
    TRISA = 0 'PORTA ALL OUTPUTS
    TRISB = %01111111 'B7 OUTPUT, ALL THE OTHERS INPUTS
    TRISC = 0 'PORTC ALL OUTPUTS
    
    DUMMY VAR BYTE
    
    <irrelevant code here>
    
    INTCON = %00001000 'PORTB CHANGE INTERRUPT ENABLED GIE *NOT* ENABLED
    NAP 0 'NAP (ENTER VERY LOW POWER MODE) FOR ABOUT 18mS.  SINCE THE WATCHDOG TIMER IS NOT ENABLED,
             'THE PROCESSOR WOULD NAP FOREVER, EXCEPT FOR THE FACT THAT THE 'INTERRUPT-ON-STATE-CHANGE'
             'BIT FOR PORTB.0 (MASTER SWITCH) IS ENABLED. THIS MEANS THAT A CHANGE ON THE MASTER SWITCH
             '(OFF TO ON) WILL GENERATE AN INTERRUPT.  HOWEVER, THE GLOBAL INTERRUPT ENABLE BIT IS *NOT*
             'SET.  THIS MEANS A *REAL* INTERRUPT WILL NOT BE GENERATED.  THE PROCESSOR WILL NOT JUMP TO THE INTERRUPT
             'ROUTINE, AND WILL, INSTEAD, EXECUTE THE NEXT INSTRUCTION AFTER THE NAP - IN OTHER WORDS, CONTINUE
             'THE MAIN LOOP WHERE THE NEW STATE OF THE MASTER SWITCH WILL BE CAUGHT BY THE IF STATEMENT.  THIS
             'HAS THE EFFECT OF SHUTTING THE PROCESSOR DOWN (ESSENTIALLY) UNTIL THE MASTER SWITCH IS TURNED ON
             'AGAIN - SAVING THE VEHICLE'S BATTERY IF THE MAIN POWER SWITCH IS ACCIDENTALLY LEFT ON.  OPERATION
             'OF ANY OF THE OTHER SWITCHES WILL NOT CAUSE THE ABOVE TO HAPPEN AS THEIR ENABLE BITS IN THE IOCB
             'REGISTER HAVE NOT BEEN SET.
    DUMMY = PORTB 'READ PORTB TO CLEAR THE MISMATCH THAT GENERATED THE INTERRUPT
    INTCON = 0 'INTERRUPTS OFF AGAIN
    "I have noticed that even those who assert that everything is predestined and that
    we can change nothing about it still look both ways before they cross the street"


    -Stephen Hawking

  6. #6
    Join Date
    Feb 2013
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: 16f883 sleeping mode

    Thanks for your help. Best Regards.

Similar Threads

  1. LCD's and Sleeping Pics
    By andybarrett1 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 1st June 2015, 18:18
  2. 16f883
    By Meriachee in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 10th September 2009, 00:45
  3. 16F883 Code Verify Problem
    By munromh in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th February 2009, 11:47
  4. 16F883/886 Help
    By plyrathrt in forum General
    Replies: 9
    Last Post: - 18th August 2008, 08:54
  5. Waking a sleeping PIC
    By anj in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th May 2005, 01:51

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