• AVR Freaks

Sleep current 6mA

Page: 12 > Showing page 1 of 2
Author
Roldan88
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2017/11/16 03:07:08
  • Location: 0
  • Status: offline
2017/11/17 05:29:55 (permalink)
0

Sleep current 6mA

Good morning everyone,
 
I have some serious current drain problems with my PIC24FJ256GA702, programmed with Pickit3.
I am running the PIC with the minimun conections, nothing else on the breadboard, all peripherial disabled (defined PMDx bits all '1's), all I/Os as output and driven low, WDT, FSCM, BOR and JTAG are all disabled, RETEN is enabled and VREGS disabled, I am using FRC oscillator at 8MHz without PLL. And when I enter to Sleep (I verify at OSC2 that the clock stops), the PIC is still draining a great amount of current. I have measured the following current drains at the above conditions while operating and in sleep:

At 3.6 V VDD, 8.9 mA in sleep, 12.2 mA operating.
At 3.3 V VDD, 7.8 mA in sleep, 10.9 mA operating.
At 3 V VDD, 6.2 mA in sleep, 9 mA operating.
At 2.8 V VDD, 5.6 mA in sleep, 8.3 mA operating.
 
For the tests reported above, the conections were as follows: 

PIN 1 (MCLR) to VDD 
PIN 8 (VSS) to GND 
PIN 13 (VDD) to VDD 
PIN 19 (VSS) to GND 
PIN 20 (VCAP) to GND (PIN 19) through a 10uF 25V electrolitic capacitor 
PIN 27 (AVSS) to GND 
PIN 28 (AVDD) to VDD 

Plus, there are 100nF ceramic capacitors between PIN 27 and PIN 28 (AVDD and AVSS) and PIN 13 and PIN 8 (VDD and VSS) 

Everything else is floating, configured as output and driven low. 
I have also tried configuring every pin as analog input, disabling ICD, etc. 
 
Here is the code, generated by MCC:
 
pin_manager.c
#include <xc.h>
#include "pin_manager.h"

/**
    void PIN_MANAGER_Initialize(void)
*/
void PIN_MANAGER_Initialize(void)
{
    /****************************************************************************
     * Setting the Output Latch SFR(s)
     ***************************************************************************/
    LATA = 0x0000;
    LATB = 0x0000;

    /****************************************************************************
     * Setting the GPIO Direction SFR(s)
     ***************************************************************************/
    TRISA = 0x0000;
    TRISB = 0x0000;

    /****************************************************************************
     * Setting the Weak Pull Up and Weak Pull Down SFR(s)
     ***************************************************************************/
    IOCPDA = 0x0000;
    IOCPDB = 0x0000;
    IOCPUA = 0x0000;
    IOCPUB = 0x0000;

    /****************************************************************************
     * Setting the Open Drain SFR(s)
     ***************************************************************************/
    ODCA = 0x0000;
    ODCB = 0x0000;

    /****************************************************************************
     * Setting the Analog/Digital Configuration SFR(s)
     ***************************************************************************/
    ANSA = 0x000F;
    ANSB = 0xF20F;
}

 
mcc.c
// Configuration bits: selected in the GUI

// FSEC
#pragma config BWRP = OFF // Boot Segment Write-Protect bit->Boot Segment may be written
#pragma config BSS = DISABLED // Boot Segment Code-Protect Level bits->No Protection (other than BWRP)
#pragma config BSEN = OFF // Boot Segment Control bit->No Boot Segment
#pragma config GWRP = OFF // General Segment Write-Protect bit->General Segment may be written
#pragma config GSS = DISABLED // General Segment Code-Protect Level bits->No Protection (other than GWRP)
#pragma config CWRP = OFF // Configuration Segment Write-Protect bit->Configuration Segment may be written
#pragma config CSS = DISABLED // Configuration Segment Code-Protect Level bits->No Protection (other than CWRP)
#pragma config AIVTDIS = OFF // Alternate Interrupt Vector Table bit->Disabled AIVT

// FOSCSEL
#pragma config FNOSC = FRC // Oscillator Source Selection->Internal Fast RC (FRC)
#pragma config PLLMODE = DISABLED // PLL Mode Selection->No PLL used; PLLEN bit is not available
#pragma config IESO = OFF // Two-speed Oscillator Start-up Enable bit->Start up with user-selected oscillator source

// FOSC
#pragma config POSCMD = NONE // Primary Oscillator Mode Select bits->Primary Oscillator disabled
#pragma config OSCIOFCN = OFF // OSC2 Pin Function bit->OSC2 is clock output
#pragma config SOSCSEL = OFF // SOSC Power Selection Configuration bits->Digital (SCLKI) mode
#pragma config PLLSS = PLL_FRC // PLL Secondary Selection Configuration bit->PLL is fed by the on-chip Fast RC (FRC) oscillator
#pragma config IOL1WAY = ON // Peripheral pin select configuration bit->Allow only one reconfiguration
#pragma config FCKSM = CSDCMD // Clock Switching Mode bits->Both Clock switching and Fail-safe Clock Monitor are disabled

// FWDT
#pragma config WDTPS = PS32768 // Watchdog Timer Postscaler bits->1:32768
#pragma config FWPSA = PR128 // Watchdog Timer Prescaler bit->1:128
#pragma config FWDTEN = OFF // Watchdog Timer Enable bits->WDT and SWDTEN disabled
#pragma config WINDIS = OFF // Watchdog Timer Window Enable bit->Watchdog Timer in Non-Window mode
#pragma config WDTWIN = WIN25 // Watchdog Timer Window Select bits->WDT Window is 25% of WDT period
#pragma config WDTCMX = WDTCLK // WDT MUX Source Select bits->WDT clock source is determined by the WDTCLK Configuration bits
#pragma config WDTCLK = LPRC // WDT Clock Source Select bits->WDT uses LPRC

// FPOR
#pragma config BOREN = OFF // Brown Out Enable bit->Brown Out Disabled
#pragma config LPCFG = ON // Low power regulator control->Retention Sleep controlled by RETEN
#pragma config DNVPEN = DISABLE // Downside Voltage Protection Enable bit->Downside protection disabled when BOR is inactive

// FICD
#pragma config ICS = NONE // ICD Communication Channel Select bits->Reserved, do not use
#pragma config JTAGEN = OFF // JTAG Enable bit->JTAG is disabled

// FDEVOPT1
#pragma config ALTCMPI = DISABLE // Alternate Comparator Input Enable bit->C1INC, C2INC, and C3INC are on their standard pin locations
#pragma config TMPRPIN = OFF // Tamper Pin Enable bit->TMPRN pin function is disabled
#pragma config SOSCHP = OFF // SOSC High Power Enable bit (valid only when SOSCSEL = 1->Enable SOSC low power mode
#pragma config ALTI2C1 = ALTI2CEN // Alternate I2C pin Location->SDA1 and SCL1 on RB9 and RB8

#include "mcc.h"

void SYSTEM_Initialize(void)
{
    PIN_MANAGER_Initialize();
    INTERRUPT_Initialize();
    OSCILLATOR_Initialize();
}

void OSCILLATOR_Initialize(void)
{
    // CF no clock failure; NOSC FRC; SOSCEN disabled; POSCEN disabled; CLKLOCK unlocked; OSWEN Switch is Complete; IOLOCK not-active;
    __builtin_write_OSCCONL((uint8_t) (0x0000 & 0x00FF));
    // CPDIV 1:1; PLLEN disabled; DOZE 1:8; RCDIV FRC; DOZEN disabled; ROI disabled;
    CLKDIV = 0x3000;
    // STOR disabled; STORPOL Interrupt when STOR is 1; STSIDL disabled; STLPOL Interrupt when STLOCK is 1; STLOCK disabled; STSRC SOSC; STEN disabled; TUN Center frequency;
    OSCTUN = 0x0000;
    // ROEN disabled; ROSEL FOSC; ROSIDL disabled; ROSWEN disabled; ROOUT disabled; ROSLP disabled;
    REFOCONL = 0x0000;
    // RODIV 0;
    REFOCONH = 0x0000;
    // ROTRIM 0;
    REFOTRIML = 0x0000;
    // DCOTUN 0;
    DCOTUN = 0x0000;
    // DCOFSEL 8; DCOEN disabled;
    DCOCON = 0x0700;
    // DIV 0;
    OSCDIV = 0x0000;
    // TRIM 0;
    OSCFDIV = 0x0000;
}


main.c
#include "mcc_generated_files/mcc.h"

#define FOSC 8000000
#define FCY (FOSC/2)
#include <libpic30.h>

int main(void)
{
    SYSTEM_Initialize();
    
    PMD1 = 0b0011100011111001; //all disabled
    PMD2 = 0b0000011100000111; //all disabled
    PMD3 = 0b0000011110000010; //all disabled
    PMD4 = 0b0000000000001110; //all disabled
    PMD5 = 0b0000000000001111; //all disabled
    PMD6 = 0b0000000000000001; //all disabled
    PMD7 = 0b0000000000110000; //all disabled
    PMD8 = 0b0000000000001100; //all disabled
    
    LATA = 0x0000;
    LATB = 0x0000;
    
    __delay_ms(5000);
    Sleep();

    while (1)
    {
        // Add your application code
    }

    return -1;
}


I have looked in the forums and in microchipknowledge without luck.
Could you help me find the problem?
 
Thank you very much for your time.
#1
qhb
Superb Member
  • Total Posts : 9998
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: Sleep current 6mA 2017/11/17 14:32:05 (permalink)
3.5 (2)
Are you disconnecting the PK3 when you measure?
 
#2
Roldan88
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2017/11/16 03:07:08
  • Location: 0
  • Status: offline
Re: Sleep current 6mA 2017/11/17 14:38:44 (permalink)
0
Hello qhb, thank you for your reply.
 
Yes, I am. If not it draws roughly 5mA more.
#3
RISC
Super Member
  • Total Posts : 5376
  • Reward points : 0
  • Status: offline
Re: Sleep current 6mA 2017/11/17 14:54:34 (permalink)
3 (1)
Hi,
You must set all pins to output mode and to their inactive level (generally low if they drive loads at high level) before  to go to sleep mode.
Regards
 
#4
Roldan88
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2017/11/16 03:07:08
  • Location: 0
  • Status: offline
Re: Sleep current 6mA 2017/11/18 01:30:08 (permalink)
0
Hello RISC,
 
Thank you for your reply.
In the code above it is what I am doing, I have also tried analog inputs, digital inputs, etc.
#5
qhb
Superb Member
  • Total Posts : 9998
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: Sleep current 6mA 2017/11/18 01:42:53 (permalink)
0
Are you powering the PIC through a regulator on your board?
Are you measuring current BEFORE, or AFTER the regulator?
 
 
#6
Roldan88
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2017/11/16 03:07:08
  • Location: 0
  • Status: offline
Re: Sleep current 6mA 2017/11/18 03:34:05 (permalink)
0
Hello qhb,
 
That is a good point, but I am powering the circuit through a battery holder with two alkaline cells in series (3 V).
I also have access to an adjustable power supply, which I made the above tests with, the outcome does not vary.
 
qhb
Are you powering the PIC through a regulator on your board?
Are you measuring current BEFORE, or AFTER the regulator?
 



#7
Sobottech
Super Member
  • Total Posts : 253
  • Reward points : 0
  • Joined: 2015/12/02 03:32:17
  • Location: 0
  • Status: offline
Re: Sleep current 6mA 2017/11/18 07:42:43 (permalink)
#8
Roldan88
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2017/11/16 03:07:08
  • Location: 0
  • Status: offline
Re: Sleep current 6mA 2017/11/18 08:30:44 (permalink)
0
Hello Sobottech,
 
Thank you for your reply. I have already read that document.
 
Sobottech
AN1416 - Low-Power Design Guide




#9
Sobottech
Super Member
  • Total Posts : 253
  • Reward points : 0
  • Joined: 2015/12/02 03:32:17
  • Location: 0
  • Status: offline
Re: Sleep current 6mA 2017/11/18 09:02:07 (permalink)
0
well, your code is not complete, so hard to tell what is going on.
Check your interrupts and post your shematic.
#10
RISC
Super Member
  • Total Posts : 5376
  • Reward points : 0
  • Status: offline
Re: Sleep current 6mA 2017/11/18 10:59:23 (permalink)
3 (1)
Hi,
Please post your code and schematic.
 
I think it probably misses some initializations.
If you use MCC you need to :
1/ uncheck all analog inputs
2/ uncheck start high
3/ uncheck Open drains if it exist
 
I also noticed you mentioned that you use a 10uF electrolytic capacitor for Vdd core.
This is not correct, you should change it to ceramic capacitor as recommended on figure 2-1.  Ceramic are much less leaky and have a low serial resistance which makes internal regulation more stable.
Regards
#11
Roldan88
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2017/11/16 03:07:08
  • Location: 0
  • Status: offline
Re: Sleep current 6mA 2017/11/18 14:14:34 (permalink)
0
Thank you for your replies, RISC and Sobottech,
 
The code is complete, "interrupt_manager.c" is empty. I defined the connections in the first post, it is the most basic circuit, nothing else is connected or in the board, only the PIC.
 
RISC, I replaced the capacitor with a 10uF tantalum I had, with no change in the current consumption. I also verified the steps you said, no configuration seems to have effect on the current drain, I tried digital inputs, digital outputs, analog outputs, all the same.
 
But there is an update, right now the PIC is draining 5.8 mA in operation and 5.3 mA in sleep, with the alkaline cells at 2.9 V. This inconsistency is driving me insane, why with the same circuit and the same program the operating current has lowered so much?
#12
Sobottech
Super Member
  • Total Posts : 253
  • Reward points : 0
  • Joined: 2015/12/02 03:32:17
  • Location: 0
  • Status: offline
Re: Sleep current 6mA 2017/11/18 15:17:19 (permalink)
3 (1)
Roldan88
But there is an update, right now the PIC is draining 5.8 mA in operation and 5.3 mA in sleep, with the alkaline cells at 2.9 V. This inconsistency is driving me insane, why with the same circuit and the same program the operating current has lowered so much?

Well, hard to tell not knowing how you do your measuring and whats your equipment and so on.
You wrote "At 2.8 V VDD, 5.6 mA in sleep, 8.3 mA operating." Well, what does this mean? 2.8V alkaline cells? Power Supply? LiPo Battery? Coin cells?
 
Is anywhere "INTERRUPT_Initialize"?
 
What is:
 
PMD1 = 0b0011100011111001; //all disabled
PMD2 = 0b0000011100000111; //all disabled
PMD3 = 0b0000011110000010; //all disabled
PMD4 = 0b0000000000001110; //all disabled
PMD5 = 0b0000000000001111; //all disabled
PMD6 = 0b0000000000000001; //all disabled
PMD7 = 0b0000000000110000; //all disabled
PMD8 = 0b0000000000001100; //all disabled
 
...
..
.
#13
Roldan88
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2017/11/16 03:07:08
  • Location: 0
  • Status: offline
Re: Sleep current 6mA 2017/11/18 15:43:09 (permalink)
0
I make the current measurements with a multimeter in series with the wire that suplies the voltage to the breadboard. In the tests of the first post, the voltage was suplied by an adjustable power supply that I have access to at work, now I am doing the tests with a battery holder with two 1.5 V AA alkaline batteries in series. With both suplies I get the same results.
I did not add the "INTERRUPT_Initialize" function nor the "interrupt_manager" files because MCC generated empty functions, no interrupt was defined.
PMD stands for Peripherial Module Disable, I am accesing those registers to manually disable all peripherials.
#14
Sobottech
Super Member
  • Total Posts : 253
  • Reward points : 0
  • Joined: 2015/12/02 03:32:17
  • Location: 0
  • Status: offline
Re: Sleep current 6mA 2017/11/18 16:42:00 (permalink)
0
Hm, ok.
 
Is there any effect using sleep in while(1) loop?
 
while (1)
{
// Add your application code
Sleep();
}
#15
Roldan88
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2017/11/16 03:07:08
  • Location: 0
  • Status: offline
Re: Sleep current 6mA 2017/11/18 17:01:38 (permalink)
0
No effect I am afraid.
 
Sobottech
Hm, ok.
 
Is there any effect using sleep in while(1) loop?
 
while (1)
{
// Add your application code
Sleep();
}




#16
Howard Long
Super Member
  • Total Posts : 676
  • Reward points : 0
  • Joined: 2005/04/04 08:50:32
  • Status: offline
Re: Sleep current 6mA 2017/11/19 06:26:02 (permalink)
4 (1)
I'd definitely need to see the full source and schematic to make a judgement.
 
In the meantime, I did a video that discusses in some depth the trials and tribulations of designing ultra low power applications that uses a pic24.
 
https: youtu.be yyoR0o5YBVI
#17
Roldan88
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2017/11/16 03:07:08
  • Location: 0
  • Status: offline
Re: Sleep current 6mA 2017/11/19 08:10:33 (permalink)
0
hank you for your reply Howard Long,
 
I will take a look at your video.
 
Here is the MPLABX project:
 
https://drive.google.com/...Harcv/view?usp=sharing
 
Howard Long
I'd definitely need to see the full source and schematic to make a judgement.
 
In the meantime, I did a video that discusses in some depth the trials and tribulations of designing ultra low power applications that uses a pic24.
 
https: youtu.be yyoR0o5YBVI




#18
Roldan88
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2017/11/16 03:07:08
  • Location: 0
  • Status: offline
Re: Sleep current 6mA 2017/11/19 08:28:55 (permalink)
#19
Roldan88
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2017/11/16 03:07:08
  • Location: 0
  • Status: offline
Re: Sleep current 6mA 2017/11/19 08:30:02 (permalink)
4 (1)
That was the schematic, I am experiencing some problems with the forum, only quick reply seems to work.
#20
Page: 12 > Showing page 1 of 2
Jump to:
© 2019 APG vNext Commercial Version 4.5