• AVR Freaks

Hot!PIC12LF1572 too much current in sleep mode

Author
umbadumba_18
New Member
  • Total Posts : 3
  • Reward points : 0
  • Joined: 2020/11/23 08:40:55
  • Location: Germany
  • Status: offline
2020/11/27 14:45:07 (permalink)
0

PIC12LF1572 too much current in sleep mode

Hi, I try to create a project with a PIC12LF1572 (XLP).
It is neccesary that the chip runs with less than 1 uA.
The PIC is normally in the sleep mode and I wake it up by a pinchange
interrupt. Everything works fine, but the chip allways consumes 7uA@3V3. The PIC is clocked
with 1MHz without PLL. The pullups are all deactivatet and the pins are fixed to high or low.
Can you give me some ideas what I can do to achive my target?
Thank you for your help.
#1

10 Replies Related Threads

    ric
    Super Member
    • Total Posts : 29435
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC12LF1572 too much current in sleep mode 2020/11/27 22:37:57 (permalink)
    0 (4)
    What are your config settings?
    Have you disabled the WDT, BOR and FVR?
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    dan1138
    Super Member
    • Total Posts : 4157
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: PIC12LF1572 too much current in sleep mode 2020/11/28 00:38:53 (permalink)
    0 (2)
    The PIC12LF1572 data sheet is not clear enough to me.
     
    I suspect that your problem is that the Fixed Voltage Reffernce(FVR) is required by the HFINTOSC, but may not go completely off when the controller enters sleep mode.
     
    This code tries to put the controller to sleep from the MFINTOSC after explicitly turning off the FVR.
    ;
    ; File:     main.S
    ; Target:   PIC12LF1572
    ; Author:   dan1138
    ; Date:     2020-11-27
    ; Compiler: pic-as(v2.31)
    ; IDE:      MPLABX v5.45
    ;
    ; Description:
    ;
    ;   Put PIC12LF1572 in lowest power configuration
    ;
    ; Add this line in the project properties box "pic-as Global Options -> Additional options":
    ;
    ;   -Wa,-a -Wl,-DCODE=2,-pResetVec=0h,-pIsr_vec=4h
    ;
        PROCESSOR   12LF1572
        PAGEWIDTH   132
        RADIX       dec
    ;
    ; Include target specific definitions for special function registers
    ;
    #include <xc.inc>
    ;
    ; Set the configuration word
    ;
     config FOSC = INTOSC    ; config FOSC = INTOSC    //  (INTOSC oscillator; I/O function on CLKIN pin)  (INTOSC oscillator; I/O function on CLKIN pin)
     config WDTE = OFF       ; Watchdog Timer Enable (WDT disabled)
     config PWRTE = OFF      ; Power-up Timer Enable (PWRT disabled)
     config MCLRE = OFF      ; MCLR Pin Function Select (MCLR/VPP pin function is digital input)
     config CP = OFF         ; Flash Program Memory Code Protection (Program memory code protection is disabled)
     config BOREN = OFF      ; Brown-out Reset Enable (Brown-out Reset disabled)
     config CLKOUTEN = OFF   ; Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
     config WRT = OFF        ; Flash Memory Self-Write Protection (Write protection off)
     config PLLEN = OFF      ; PLL Enable (4x PLL disabled)
     config STVREN = ON      ; Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
     config BORV = LO        ; Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
     config LPBOREN = OFF    ; Low Power Brown-out Reset enable bit (LPBOR is disabled)
     config LVP = OFF        ; Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming)
    ;
    ; Reset vector
    ;
        PSECT   ResetVec,class=CODE,delta=2
        global  ResetVector
    ResetVector:
        goto    Start
    ;
    ;   Interrupt vector and handler
        PSECT   Isr_vec,global,class=CODE,delta=2
        GLOBAL  IsrVec
    ;
    IsrVec:
        retfie                      ; Return from interrupt
    ;
        PSECT   StartCode,class=CODE,delta=2
        global  Start
    Start:
        clrf    INTCON
        bsf     INTCON,INTCON_PEIE_POSITION
        banksel PIE1
        clrf    BANKMASK(PIE1)
        clrf    BANKMASK(PIE2)
        clrf    BANKMASK(PIE3)
        banksel PIR1
        clrf    BANKMASK(PIR1)
        clrf    BANKMASK(PIR2)
        clrf    BANKMASK(PIR3)
        banksel ANSELA
        bcf     BANKMASK(ANSELA),ANSELA_ANSA2_POSITION
        banksel OPTION_REG
        bsf     BANKMASK(OPTION_REG),OPTION_REG_INTEDG_POSITION
        bsf     INTCON,INTCON_INTE_POSITION
    ;
    ; This is only for the PIC12F1572
    ;
    #if defined(VREGCON)
        banksel VREGCON
        bsf     VREGCON,VREGCON_VREGPM_POSITION
    #endif
    ;
    ; The system oscillator is set for MFINTOSC at 500KHz
    ; because the Fixed Voltage Refference cannot be turned
    ; off when the HFINTOSC is enabled.
    ;
        banksel OSCCON
        movlw   0x3A
        movwf   BANKMASK(OSCCON)
        movlw   0
    WaitForMFINTOSC:
        addlw   1
        btfsc   STATUS,STATUS_Z_POSITION
        goto    WaitTimeout
        btfss   BANKMASK(OSCSTAT),OSCSTAT_MFIOFR_POSITION
        goto    WaitForMFINTOSC
    WaitTimeout:
        banksel FVRCON
        clrf    BANKMASK(FVRCON)
        banksel PORTA
    Loop:
        bcf     INTCON,INTCON_INTF_POSITION
        sleep
        nop             ; wait for low to high transition of RA2 to wake.
    Wake:
        btfsc   PORTA,PORTA_RA2_POSITION
        goto    Wake    ; stay awake when RA2/INT is high
        goto    Loop

        end     ResetVector

     
    post edited by dan1138 - 2020/11/28 00:41:21
    #3
    davea
    Super Member
    • Total Posts : 585
    • Reward points : 0
    • Joined: 2016/01/28 13:12:13
    • Location: Tampa Bay FL USA
    • Status: offline
    Re: PIC12LF1572 too much current in sleep mode 2020/11/28 00:54:22 (permalink)
    0
    The pullups are all deactivatet and the pins are fixed to high or low

    including the 2 programming pins, if not turn on weak pullups for them 
    does not effect debugging 
    #4
    Howard Long
    Super Member
    • Total Posts : 861
    • Reward points : 0
    • Joined: 2005/04/04 08:50:32
    • Status: offline
    Re: PIC12LF1572 too much current in sleep mode 2020/11/28 02:53:57 (permalink)
    +3 (3)
    I achieve 15nA @3.3V and 14nA @1.8V with this device and the following code, measured with a Keithley 236 SMU.
     
    All GPIOs disconnected, except RA2 which is a 220 ohm in series with a red LED to ground, MCLR 10k to Vdd.
     
    Make sure you remove your programmer/debugger when taking measurements, and that your PCB has been cleaned properly (e.g. ultrasonic bath) to properly remove any ionic contaminants such as flux.
     


    // PIC12LF1572 Configuration Bit Settings
    // 'C' source line config statements
    // CONFIG1
    #pragma config FOSC = INTOSC // (INTOSC oscillator; I/O function on CLKIN pin)
    #pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
    #pragma config PWRTE = OFF // Power-up Timer Enable (PWRT disabled)
    #pragma config MCLRE = ON // MCLR Pin Function Select (MCLR/VPP pin function is MCLR)
    #pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
    #pragma config BOREN = OFF // Brown-out Reset Enable (Brown-out Reset disabled)
    #pragma config CLKOUTEN = ON // Clock Out Enable (CLKOUT function is enabled on the CLKOUT pin)
    // CONFIG2
    #pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
    #pragma config PLLEN = OFF // PLL Enable (4x PLL disabled)
    #pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
    #pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
    #pragma config LPBOREN = OFF // Low Power Brown-out Reset enable bit (LPBOR is disabled)
    #pragma config LVP = ON // Low-Voltage Programming Enable (Low-voltage programming enabled)
    // #pragma config statements should precede project file includes.
    // Use project enums instead of #define for ON and OFF.
    #include <xc.h>
    #define _XTAL_FREQ 500000
    int main(void)
    {
    TRISA=0;
    ANSELA=0;
    LATAbits.LATA2=1;
    __delay_ms(250);
    LATAbits.LATA2=0;
    __delay_ms(250);
    LATAbits.LATA2=1;
    __delay_ms(250);
    LATAbits.LATA2=0;
    __delay_ms(250);
    LATAbits.LATA2=1;
    __delay_ms(2000);
    LATAbits.LATA2=0;
    SLEEP();

    while (1)
    {
    }
    return 0;
    }

    Attached Image(s)

    #5
    NKurzman
    A Guy on the Net
    • Total Posts : 19106
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: PIC12LF1572 too much current in sleep mode 2020/11/28 09:44:40 (permalink)
    +2 (2)
    Additionally, how are you measuring current?
    Mini cheap multimeters have difficulty measuring microamps accurately.
    #6
    umbadumba_18
    New Member
    • Total Posts : 3
    • Reward points : 0
    • Joined: 2020/11/23 08:40:55
    • Location: Germany
    • Status: offline
    Re: PIC12LF1572 too much current in sleep mode 2020/12/01 12:39:14 (permalink)
    0
    It is solved!  Now I have less than 100nA@3V3. The reason was that I wasn't able to change the  #pragma config "BOREN" to "OFF"  My compiler showed me always an error.  At first I thought it isn't possible to switch to "OFF" because I use the LF version of the controller. I created a fresh project with my  copied code from my current project and then the compiler worked witout errors.

    Thank you for your help.  

    Now I use the following pragmas:

    // PIC12LF1572 Configuration Bit Settings
    // 'C' source line config statements
    // CONFIG1
    #pragma config FOSC = INTOSC // (INTOSC oscillator; I/O function on CLKIN pin)
    #pragma config WDTE = OFF // Watchdog Timer Enable (WDT disabled)
    #pragma config PWRTE = OFF // Power-up Timer Enable (PWRT disabled)
    #pragma config MCLRE = OFF // ON MCLR Pin Function Select (MCLR/VPP pin function is MCLR)
    #pragma config CP = OFF // Flash Program Memory Code Protection (Program memory code protection is disabled)
    #pragma config BOREN = OFF // Brown-out Reset Enable (Brown-out Reset disabled)
    #pragma config CLKOUTEN = OFF // Clock Out Enable (CLKOUT function is enabled on the CLKOUT pin)
    // CONFIG2
    #pragma config WRT = OFF // Flash Memory Self-Write Protection (Write protection off)
    #pragma config PLLEN = OFF // PLL Enable (4x PLL disabled)
    #pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
    #pragma config BORV = LO // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
    #pragma config LPBOREN = OFF // Low Power Brown-out Reset enable bit (LPBOR is disabled)
    #pragma config LVP = ON // Low-Voltage Programming Enable (Low-voltage programming enabled)
    // #pragma config statements should precede project file includes.
    // Use project enums in
    #7
    ric
    Super Member
    • Total Posts : 29435
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: PIC12LF1572 too much current in sleep mode 2020/12/01 14:27:50 (permalink)
    +3 (3)
    So my post#2, which correctly indicated the final problem, someone thought was worth "-1" ...
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #8
    upand_at_them
    Super Member
    • Total Posts : 765
    • Reward points : 0
    • Joined: 2005/05/16 07:02:38
    • Location: Pennsylvania
    • Status: offline
    Re: PIC12LF1572 too much current in sleep mode 2020/12/01 15:16:55 (permalink)
    +1 (1)
    ricSo my post#2, which correctly indicated the final problem, someone thought was worth "-1" ...

     
    And this is why I hate the rating mechanism on here; it's meaningless.
    #9
    dan1138
    Super Member
    • Total Posts : 4157
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: PIC12LF1572 too much current in sleep mode 2020/12/01 15:22:32 (permalink)
    0
    umbadumba_18
    It is solved!  Now I have less than 100nA@3V3.

    I cannot find an LF controller so tested with the PIC12F1572 and it is less than 800na.
    #10
    dan1138
    Super Member
    • Total Posts : 4157
    • Reward points : 0
    • Joined: 2007/02/21 23:04:16
    • Location: 0
    • Status: offline
    Re: PIC12LF1572 too much current in sleep mode 2020/12/01 15:26:09 (permalink)
    -1 (1)
    ric
    So my post#2, which correctly indicated the final problem, someone thought was worth "-1" ...

    Your troll been doing a lot of down votes lately.
    #11
    Jump to:
    © 2021 APG vNext Commercial Version 4.5