PIC16F15313: Achieving minimal current at 32kHz

Thread Starter


Joined Jan 5, 2016
Hi circuiteers

I'm struggling to get close to the datasheets XLP characteristics, pasted below. I'm running at 5V and putting the PIC to sleep for 4s intervals but it's still consuming 28uA when asleep. I believe I should easily achieve sub-1uA@5V. I have included the code below, which is minimal. I'd expect all peripherals to be OFF by default. I unplugged the PIC and the current when to <100nA (cap leakage) so I sure it's the PIC consuming the 28uA. Does anyone know why I'm missing my target? Any help gratefully received

#define _XTAL_FREQ 32000

// PIC16F15313 Configuration Bit Settings

// 'C' source line config statements

#pragma config FEXTOSC = OFF    // External Oscillator mode selection bits (Oscillator not enabled)
//#pragma config RSTOSC = HFINT1  // Power-up default value for COSC bits (HFINTOSC (1MHz))
#pragma config RSTOSC = LFINT   // Power-up default value for COSC bits (LFINTOSC)
#pragma config CLKOUTEN = OFF   // Clock Out Enable bit (CLKOUT function is disabled; i/o or oscillator function on OSC2)
#pragma config CSWEN = ON       // Clock Switch Enable bit (Writing to NOSC and NDIV is allowed)
#pragma config FCMEN = ON       // Fail-Safe Clock Monitor Enable bit (FSCM timer enabled)

#pragma config MCLRE = ON       // Master Clear Enable bit (MCLR pin is Master Clear function)
#pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
#pragma config LPBOREN = OFF    // Low-Power BOR enable bit (ULPBOR disabled)
#pragma config BOREN = ON       // Brown-out reset enable bits (Brown-out Reset Enabled, SBOREN bit is ignored)
#pragma config BORV = LO        // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (VBOR) set to 1.9V on LF, and 2.45V on F Devices)
#pragma config ZCD = OFF        // Zero-cross detect disable (Zero-cross detect circuit is disabled at POR.)
#pragma config PPS1WAY = ON     // Peripheral Pin Select one-way control (The PPSLOCK bit can be cleared and set only once in software)
#pragma config STVREN = ON      // Stack Overflow/Underflow Reset Enable bit (Stack Overflow or Underflow will cause a reset)

#pragma config WDTCPS = WDTCPS_31// WDT Period Select bits (Divider ratio 1:65536; software control of WDTPS)
#pragma config WDTE = ON        // WDT operating mode (WDT enabled regardless of sleep; SWDTEN ignored)
#pragma config WDTCWS = WDTCWS_7// WDT Window Select bits (window always open (100%); software control; keyed access not required)
#pragma config WDTCCS = LFINTOSC// WDT input clock selector (WDT reference clock is the 31.0kHz LFINTOSC output)

#pragma config BBSIZE = BB512   // Boot Block Size Selection bits (512 words boot block size)
#pragma config BBEN = OFF       // Boot Block Enable bit (Boot Block disabled)
#pragma config SAFEN = OFF      // SAF Enable bit (SAF disabled)
#pragma config WRTAPP = OFF     // Application Block Write Protection bit (Application Block not write protected)
#pragma config WRTB = OFF       // Boot Block Write Protection bit (Boot Block not write protected)
#pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration Register not write protected)
#pragma config WRTSAF = OFF     // Storage Area Flash Write Protection bit (SAF not write protected)
#pragma config LVP = OFF         // Low Voltage Programming Enable bit (Low Voltage programming enabled. MCLR/Vpp pin function is MCLR.)

#pragma config CP = OFF         // UserNVM Program memory code protection bit (UserNVM code protection disabled)

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#include <xc.h>

void main(void) {
    TRISA = 0;
    PORTAbits.RA3 = 1;
        // flash LED briefly
        PORTAbits.RA0 = 1;
        PORTAbits.RA0 = 0;
        // go to sleep, setting WDT first
        WDTCON0bits.WDTPS = 0b01100; // 4s @ 32kHz
        WDTCON0bits.SWDTEN = 1; // enable
        WDTCON0bits.SWDTEN = 0; // disable

Thread Starter


Joined Jan 5, 2016
Ok, got this down to 11uA by adding the line below. Still way off my target
        // go to sleep, setting WDT first
        VREGCONbits.VREGPM = 1; // LP sleep mode: reduces I 28uA-->11uA


Joined Feb 19, 2010
Did you notice 1.8V references?
They are telling you that you will get those tiny currents when your system voltage is 1.8V.

Thread Starter


Joined Jan 5, 2016
Ok this is embarrassing. Got it down to 800nA by turning ofF the Brown out module. Had no idea this would consume so much current. Problem solved
#pragma config BOREN = OFF      // Brown-out reset enable bits (Brown-out reset disabled)


Joined Jun 4, 2014
Check section 16 of the datasheet.
The PIC16(L)F15313/23 provides the ability to disable
selected modules, placing them into the lowest
possible Power mode.
For legacy reasons, all modules are ON by default
following any Reset.