Low power aplication on 12F629


Results 1 to 9 of 9

Threaded View

  1. #4
    Join Date
    Feb 2011
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Re: Low power aplication on 12F629

    Try the 12f635 or the 12f683.

    The 12F629 does not have the OSCCON @ [8F - hex] , register so you can't set the speed it is stuck at 4MHz.
    You will need to read the DATA SHEET a bit more closely -- as always it is buried in the fineprint

    some hints: * learned from observation, please let me know if I'm wrong : )

    0. Set the 2007 Register BIT FIVE [5] to ZERO [0] *****************
    ----> I currently do this just before programming in the programmer configuration menu.
    ***** This disables the master reset and allows you a. to ignore it, b. use GPIO.3 as an input. ---> for the pros I have not figured out how to set this in PBasic. more rtf is in order.

    1. SLEEP and NAP are not affected by the cpu speed [really helpful]
    2. PAUSE will be affected by the timer speed, >> will shift the number
    3. To save power turn off the outputs when you are not using them ie. TRISIO = $FF
    --- You can use this instead of GPIO = XX to turn off your lamps

    I also had trouble with setting PBasic to work on slow CPU

    Here's my kludge on the 12f683 : )

    This is blinking some lights in a special pattern [code not shown] when off the cpu uses between 40-60 nano Amp!! Yes, NANO amps!
    on a cr2016
    Code:
    -----------------------------------------------
    The circuit is:
    pin
    1 - BATT+  not even a cap to pin.8 [ground] :)
    2 - LED1 +
    3 - LED2 +
    4 - NC
    5 - LED3 +
    6 - LED4 +
    7 - BUZZER.minus ---> *** this PIN is a SINK, shorts to ground so turn it to ZERO in GPIO.0 when you want it to work -- other end of the BUZZER TO to batt+, use GPIO.0
    8- BATT -
    
    LED1-4 - combined together then 100ohm to pin.8 [ground]

    My typical header -- all commented on 12f683 for this program
    Code:
    '
    ' FOR LOW POWER DISABLE AS MANY FEATURES AS POSSIBLE.
    ' ** FOR 12F675 un-COMMENT CMCON=7, ANSEL=0, ADCON0=0
    ' ** FOR 12F629 COMMENT ALL
     '   CMCON = $07  'CMCON — COMPARATOR CONTROL REGISTER  ALL DIGITAL
    '    TRISIO = %11111011   '  tristate mode  1=INPUT
    ' 	TRISA  = %00001000	' Set PORTA.0 to input   A.3 input ONLY  1=in
    ' 	TRISA  = %00001000	' Set PORTA.3 input
    '	ADCON1 = %01100000	' Set a2d convert at clk/6 [slowest]
    '	ADCON1 = %00000000	' Set a2d convert at clk/2 [fastest]
    '	ANSEL  = %00000000  ' AN0/RA0 as analog input     1=ANALOG
    '	ADCON0 = %00000001	' .7=10bits left justify result!! / .0 1=a2d ON
    '	ADCON0 = %00000000	' .7=10bits left justify result!! / .0 1=a2d ON
    '   WPUA =   %00000000  ' TURN ON WEAK PULLUP 1=ON VALID=.5.4.2.1.0

    Code:
    ' lifted right from the data sheet     : )
    '
    'low speed osccon 31khz 
    ''bit 6-4 IRCF<2:0>: Internal Oscillator Frequency Select bits
    '                               correction 
    '                               by shifting
    '                                   |
    '                                   v
    '       111 =8MHz
    '       110 =4MHz (default)         0
    '       101 =2MHz                   1   2
    '       100 =1MHz                   2   4
    '       011 =500kHz                 3   8
    '       010 =250kHz                 4   16
    '       001 =125kHz                 5   32
    '       000 =31kHz (LFINTOSC)       7   128
    
            OSCCON.6 = 0
            OSCCON.5 = 0
            OSCCON.4 = 0
    speed_shift  CON   7   '  use 0-7 : oscillator / delay correction by shifting
    
    
    ' BYTES
    led           VAR byte   '  lower 6 bits only  for GPIO
    
    ' WORDS
    X       var	word
    
    
    ' TEST ALL LAMPS GPIO.1.2.4  3=INPUT ONLY
    
    ' Delay for ~3 seconds
    X= 3000     ' START UP DELAY TIME
    '
    ' could of done this as a short gosub 
    '
    led =    $02 
    TRISIO = $FE - led
    GPIO =   led
    Pause X >> speed_shift       ' Delay for on time in milliseconds
    led =    $04 
    TRISIO = $FF - led
    GPIO =   led
    Pause X >> speed_shift       ' Delay for on time in milliseconds
    led =    $10 
    TRISIO = $FE - led
    GPIO =   led
    Pause X >> speed_shift       ' Delay for on time in milliseconds
    led =    $20 
    TRISIO = $FF - led
    GPIO =   led
    Pause X >> speed_shift       ' Delay for on time in milliseconds
    
    
    ....
    
    
     LED = %00110110                    ' GPIO.1.2.4.5
      
         TRISIO = $FF    ' TURN OFF OUTPUTS TO SAVE POWER
         GPIO= led       ' Chose which LED to Turn ON
    
    
    ' LED ON fast blink # led 
         TRISIO = $FF - led  ' Enable output - fast blink # led
        Pause  128  >> speed_shift 
    
    ' LED OFF
        TRISIO = $FF    ' TURN OFF OUTPUTS TO SAVE POWER
        Pause  256  >> speed_shift      'time in mS
    
    end
    Last edited by ofuzzy1; - 23rd February 2011 at 03:25.

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