• AVR Freaks

Hot!PIC32MM in Sleep Mode takes 5 mA ??!!

Page: < 12 Showing page 2 of 2
Author
Howard Long
Super Member
  • Total Posts : 676
  • Reward points : 0
  • Joined: 2005/04/04 08:50:32
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/21 16:15:25 (permalink)
+1 (1)
FWIW I get the following sleep figures all at 3.3V, all peripherals off on a PIC32MM0064GPL028. INT0 falling edge will wake up.
 
Be very careful with retention sleep modes, or you risk bricking your chip!!!!
 
Run:
8MHz 3.43mA
 
Sleep (see DS60001324C Table 22-2):
Normal 136uA
Standby only 4.98uA
Retention only 2.52uA
Standby & retention 327nA
 


// PIC32MM0064GPL028 Configuration Bit Settings
// 'C' source line config statements
// FDEVOPT
#pragma config SOSCHP = OFF // Secondary Oscillator High Power Enable bit (SOSC oprerates in normal power mode.)
#pragma config USERID = 0xFFFF // User ID bits (Enter Hexadecimal value)
// FICD
#pragma config JTAGEN = OFF // JTAG Enable bit (JTAG is disabled)
#pragma config ICS = PGx1 // ICE/ICD Communication Channel Selection bits (Communicate on PGEC1/PGED1)
// FPOR
#pragma config BOREN = BOR0 // Brown-out Reset Enable bits (Brown-out Reset disabled in hardware; SBOREN bit disabled)
//#pragma config RETVR = OFF // Retention Voltage Regulator Enable bit (Retention regulator is disabled)
#pragma config RETVR = ON // Retention Voltage Regulator Enable bit (Retention regulator is enabled and controlled by RETEN bit during sleep)
#pragma config LPBOREN = OFF // Low Power Brown-out Enable bit (Low power BOR is disabled)
// FWDT
#pragma config SWDTPS = PS1048576 // Sleep Mode Watchdog Timer Postscale Selection bits (1:1048576)
#pragma config FWDTWINSZ = PS25_0 // Watchdog Timer Window Size bits (Watchdog timer window size is 25%)
#pragma config WINDIS = OFF // Windowed Watchdog Timer Disable bit (Watchdog timer is in non-window mode)
#pragma config RWDTPS = PS1048576 // Run Mode Watchdog Timer Postscale Selection bits (1:1048576)
#pragma config RCLKSEL = LPRC // Run Mode Watchdog Timer Clock Source Selection bits (Clock source is LPRC (same as for sleep mode))
#pragma config FWDTEN = OFF // Watchdog Timer Enable bit (WDT is disabled)
// FOSCSEL
#pragma config FNOSC = FRCDIV // Oscillator Selection bits (Fast RC oscillator (FRC) with divide-by-N)
#pragma config PLLSRC = FRC // System PLL Input Clock Selection bit (FRC oscillator is selected as PLL reference input on device reset)
#pragma config SOSCEN = OFF // Secondary Oscillator Enable bit (Secondary oscillator is disabled)
#pragma config IESO = OFF // Two Speed Startup Enable bit (Two speed startup is disabled)
#pragma config POSCMOD = OFF // Primary Oscillator Selection bit (Primary oscillator is disabled)
//#pragma config OSCIOFNC = OFF // System Clock on CLKO Pin Enable bit (OSCO pin operates as a normal I/O)
#pragma config OSCIOFNC = ON // System Clock on CLKO Pin Enable bit (System clock is connected to CLKO/OSC2 pin)
#pragma config SOSCSEL = OFF // Secondary Oscillator External Clock Enable bit (SOSC pins configured for Crystal mode)
#pragma config FCKSM = CSECMD // Clock Switching and Fail-Safe Clock Monitor Enable bits (Clock switching is enabled; Fail-safe clock monitor is disabled)
// FSEC
#pragma config CP = OFF // Code Protection Enable bit (Code protection is disabled)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#include <xc.h>
#include <stdint.h>
#define FCY 8000000
void MyDelayMS(uint32_t u32)
{
uint32_t u32End=_CP0_GET_COUNT()+u32*(FCY/2/1000);

while ((int32_t)u32End-(int32_t)_CP0_GET_COUNT()>0)
{
Nop();
}
}
int main(void)
{
LATA=0;
LATB=0;
TRISA=0;
TRISB=0x8000; // INT0 is RB15
CNPUBbits.CNPUB15=1; // Weak pullup on RB15/INT0
IFS0bits.INT0IF=0;
IEC0bits.INT0IE=1;
IPC0bits.INT0IP=3;
INTCONbits.INT0EP=0; // Falling edge allows wakeup
ANSELA=0;
ANSELB=0;

SYSKEY=0xAA996655;
SYSKEY=0x556699AA;
OSCCONbits.SLPEN=1;
PWRCONbits.VREGS=1;
PWRCONbits.RETEN=1;
PMDCONbits.PMDLOCK=0;
PMD1=0xFFFFFFFF;
PMD2=0xFFFFFFFF;
PMD3=0xFFFFFFFF;
PMD4=0xFFFFFFFF;
PMD5=0xFFFFFFFF;
PMD6=0xFFFFFFFF;
PMD7=0xFFFFFFFF;
PMDCONbits.PMDLOCK=1;
SYSKEY=0x00000000;

while (1)
{
LATBbits.LATB5=1;
MyDelayMS(2000);
LATBbits.LATB5=0;
_wait();
IFS0bits.INT0IF=0;
Nop();
}
}

 
 
#21
wku
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2018/05/19 02:34:15
  • Location: Poland
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/22 13:41:13 (permalink)
0
Hi Howard Long
Thank you very much for answering and your program, I will check at home how it works 
Playing with Retention modes and BOR I blocked the chip :) I can't program it. It receives such a message in the annex
But it's not a big problem because I still have PIC32MM and tiles in stock :)

Attachment(s)

Attachments are not available: Download requirements not met

strefapic.blogspot.com
#22
wku
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2018/05/19 02:34:15
  • Location: Poland
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/23 02:29:13 (permalink)
0
Hello
My measurements currently for PIC32MM0256GPM048 :
Run mode FRC 8 MHz, all PMDx= 0, pins not adjustable : 3.8 mA  (very nice)
code below :
#include "mcc_generated_files/system.h"


int main(void)
{
    // initialize the device
    SYSTEM_Initialize();
    while (1)
    {
        Nop();
    }
    return 1;
}

Attachment(s)

Attachments are not available: Download requirements not met

strefapic.blogspot.com
#23
wku
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2018/05/19 02:34:15
  • Location: Poland
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/23 02:39:31 (permalink)
0
Hi Howard Long
How did you set the pins?  Output from pull-up to Vcc, is it a good choice?

strefapic.blogspot.com
#24
qhb
Superb Member
  • Total Posts : 9998
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/23 04:15:47 (permalink)
+1 (1)
wku
How did you set the pins?  Output from pull-up to Vcc, is it a good choice?

What does this mean?
If a pin is an output, it doesn't need a pullup.
If the pullup is there, then either drive the pin high, or make it an input.
Do NOT drive it low, or you will be wasting current through the pullup resistor.

Nearly there...
#25
wku
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2018/05/19 02:34:15
  • Location: Poland
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/23 04:31:49 (permalink)
0
You are right, I wrote badly.

strefapic.blogspot.com
#26
Howard Long
Super Member
  • Total Posts : 676
  • Reward points : 0
  • Joined: 2005/04/04 08:50:32
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/23 04:38:07 (permalink)
+1 (1)
All GPIO were disconnected except MCLR and INT0 (RB15).

All TRIS bits should be 0 except RB15 (INT0).

All LAT bits should be set to 0.

All ANSEL bits should be set to 0.

MCLR has a 10k pull up.

For INT0 I configured an internal pull up.

Because the 28 pin device only has A and B ports, you should also set the additional LATC, TRISC and ANSELC bits appropriately on your 48 pin device.

Furthermore, as your device has USB, there may be a USB bit you need to set as well as the PMD bits to get low power, I have seen this in some PIC32MX OTG implementations (USUSPEND). See my post here https://www.microchip.com/forums/FindPost/1083497

In addition, the current draw sounds very much like the oscillator’s still running. You’ll notice I use OSCIOFNC = ON: this lets you probe CLKO when using the internal FRC to see if it’s running or not.

If I get chance later today I’ll try this out on a PIC32MM Curiosity board, but I don’t know yet what else is on that board that might draw current.
#27
wku
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2018/05/19 02:34:15
  • Location: Poland
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/23 04:57:08 (permalink)
0
Thank you Howard Long you helped me a lot, You are my idol :)

strefapic.blogspot.com
#28
Howard Long
Super Member
  • Total Posts : 676
  • Reward points : 0
  • Joined: 2005/04/04 08:50:32
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/23 09:16:59 (permalink)
+2 (2)
This is on the PIC32MM USB Curiosity board DM320107. I didn't need to turn on USUSPEND to achieve these sleep figures. They're measured at J6, with the track underneath cut.
 
LED turns on for 2s, then switches off and the board goes into sleep. To wake up, press S1 (INT2/RB9).
 
VREGS / RETEN / RETVR / MODE / Current
1 / 0 / OFF (1) / 1 / Normal 139uA
0 / 0 / OFF (1) / 1 / Standby 5.02uA
1 / 1 / ON (0)  / 1 / Retention only 2.70uA
0 / 1 / ON (0)  / 1 / Standby & retention 384nA
 

 
// PIC32MM0256GPM064 Configuration Bit Settings
 
// 'C' source line config statements
 
// FDEVOPT
#pragma config SOSCHP = OFF // Secondary Oscillator High Power Enable bit (SOSC oprerates in normal power mode.)
#pragma config ALTI2C = OFF // Alternate I2C1 Pins Location Enable bit (Primary I2C1 pins are used)
#pragma config FUSBIDIO = OFF // USBID pin control (USBID pin is controlled by the USB module)
#pragma config FVBUSIO = OFF // VBUS Pin Control (VBUS pin is controlled by the USB module)
#pragma config USERID = 0xFFFF // User ID bits (Enter Hexadecimal value)
 
// FICD
#pragma config JTAGEN = OFF // JTAG Enable bit (JTAG is disabled)
#pragma config ICS = PGx2 // ICE/ICD Communication Channel Selection bits (Communicate on PGEC2/PGED2)
 
// FPOR
#pragma config BOREN = BOR0 // Brown-out Reset Enable bits (Brown-out Reset disabled in hardware; SBOREN bit disabled)
//#pragma config RETVR = OFF // Retention Voltage Regulator Enable bit (Retention regulator is disabled)
#pragma config RETVR = ON // Retention Voltage Regulator Enable bit (Retention regulator is enabled and controlled by RETEN bit during sleep)
#pragma config LPBOREN = OFF // Downside Voltage Protection Enable bit (Low power BOR is disabled)
 
// FWDT
#pragma config SWDTPS = PS1048576 // Sleep Mode Watchdog Timer Postscale Selection bits (1:1048576)
#pragma config FWDTWINSZ = PS25_0 // Watchdog Timer Window Size bits (Watchdog timer window size is 25%)
#pragma config WINDIS = OFF // Windowed Watchdog Timer Disable bit (Watchdog timer is in non-window mode)
#pragma config RWDTPS = PS1048576 // Run Mode Watchdog Timer Postscale Selection bits (1:1048576)
#pragma config RCLKSEL = LPRC // Run Mode Watchdog Timer Clock Source Selection bits (Clock source is LPRC (same as for sleep mode))
#pragma config FWDTEN = OFF // Watchdog Timer Enable bit (WDT is disabled)
 
// FOSCSEL
#pragma config FNOSC = FRCDIV // Oscillator Selection bits (Fast RC oscillator (FRC) with divide-by-N)
#pragma config PLLSRC = FRC // System PLL Input Clock Selection bit (FRC oscillator is selected as PLL reference input on device reset)
#pragma config SOSCEN = OFF // Secondary Oscillator Enable bit (Secondary oscillator is disabled)
#pragma config IESO = OFF // Two Speed Startup Enable bit (Two speed startup is disabled)
#pragma config POSCMOD = OFF // Primary Oscillator Selection bit (Primary oscillator is disabled)
#pragma config OSCIOFNC = ON // System Clock on CLKO Pin Enable bit (System clock is connected to CLKO/OSC2 pin)
#pragma config SOSCSEL = OFF // Secondary Oscillator External Clock Enable bit (SOSC pins configured for Crystal mode)
#pragma config FCKSM = CSECMD // Clock Switching and Fail-Safe Clock Monitor Enable bits (Clock switching is enabled; Fail-safe clock monitor is disabled)
 
// FSEC
#pragma config CP = OFF // Code Protection Enable bit (Code protection is disabled)
 
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
 
#include <xc.h>
 
#include <stdint.h>
#define FCY 8000000
 
void MyDelayMS(uint32_t u32)
{
uint32_t u32End=_CP0_GET_COUNT()+u32*(FCY/2/1000);

while ((int32_t)u32End-(int32_t)_CP0_GET_COUNT()>0)
{
Nop();
}
}
 
int main(void)
{
LATA=0;
LATB=0;
LATC=0;
LATD=0;
TRISA=0;
TRISB=0x0200; // INT2 is RB9 (and S1 on Curiosity board)
TRISC=0;
TRISD=0;
ANSELA=0;
ANSELB=0;
ANSELC=0;
ANSELD=0;
 
// Enable INT2 for wakeup
CNPUBbits.CNPUB9=1; // Weak pullup on RB9/INT2/S1
IFS0bits.INT2IF=0;
IEC0bits.INT2IE=1;
IPC1bits.INT2IP=3;
INTCONbits.INT2EP=0; // Falling edge allows wakeup

SYSKEY=0xAA996655;
SYSKEY=0x556699AA;
OSCCONbits.SLPEN=1;
PWRCONbits.VREGS=0;
PWRCONbits.RETEN=1;
PMDCONbits.PMDLOCK=0;
PMD1=0xFFFFFFFF;
PMD2=0xFFFFFFFF;
PMD3=0xFFFFFFFF;
PMD4=0xFFFFFFFF;
PMD5=0xFFFFFFFF;
PMD6=0xFFFFFFFF;
PMD7=0xFFFFFFFF;
PMDCONbits.PMDLOCK=1;
SYSKEY=0x00000000;
 
while (1)
{
LATDbits.LATD3=1; // LED1 on Curiosity board
MyDelayMS(2000);
LATDbits.LATD3=0; // LED1 on Curiosity board
_wait();
IFS0bits.INT2IF=0;
Nop();
}
 
return 0;
}
 

#29
wku
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2018/05/19 02:34:15
  • Location: Poland
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/23 12:13:20 (permalink)
0
Hello Howard Long
Nice you have the results
I have Sleep Mode and that's enough for me. I want to have a quick wake up
PIC32MM0256GPM048 (48 pin)
FRC 8MHz , Peripherials OFF, Pins set Output : 36 uA
 
#include "mcc_generated_files/system.h"

int main(void)
{
    // initialize the device
    SYSTEM_Initialize();
    PMDx_OFF(); //peripheral OFF
    SYSTEM_RegUnlock(); //unlock registers
    OSCCONbits.SLPEN=1; //enable Sleep mode
    SYSTEM_RegLock(); //lock registers
               
    _wait();
    
    while (1)
    {
        Nop();
    }
    return 1;
}

 

strefapic.blogspot.com
#30
wku
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2018/05/19 02:34:15
  • Location: Poland
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/24 01:55:32 (permalink)
0
My "record" for Sleep Mode 
PWRCONbits.VREGS = 0 
PWRCONbits.RETEN = 0
= 4 uA for FRC 8MHz

strefapic.blogspot.com
#31
wku
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2018/05/19 02:34:15
  • Location: Poland
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/24 11:17:08 (permalink)
0
Hello
 
I slept deep into the PIC32MM without waking it up and I can't program in MPLABX-IDE  it you have any idea. My programmer is PICkit3. The message I receive when I try to upload a program in MPLABX-IDE is :
Failed to program device
Selected device and target: memory mismatch.

strefapic.blogspot.com
#32
Howard Long
Super Member
  • Total Posts : 676
  • Reward points : 0
  • Joined: 2005/04/04 08:50:32
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/24 13:22:13 (permalink)
+1 (1)
That’s the error you get on a PICkit 3 when the target’s bricked.

I have a couple of devices in the same state.

I’ve been unable to bring them back to life so far with any of the tricks, including using a special PICkit2 dat file,

As a result, I deliberately make my code so it’s awake for a couple of seconds after reset so I can sneak an erase in.
post edited by Howard Long - 2019/03/24 13:38:52
#33
wku
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2018/05/19 02:34:15
  • Location: Poland
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/24 23:19:29 (permalink)
0
Hi Howard Long
I found such a solution but I don't have an ICD3 :) My colleague has an ICD3 and I will give it to him, we will see if this method works.
 
I corrected the problem as follows:
- I use ICD3, PIC32MM0256
- for the MCLR signal I connected the capacitor cca 100uF (MCLR-GND), no need to solder, just plug in the connector
- start programming
- mplab reports an error, but it does not matter
- remove the capacitor and re-program it
- now it was no problem
- I tried on two chips and every time I succeeded

strefapic.blogspot.com
#34
Howard Long
Super Member
  • Total Posts : 676
  • Reward points : 0
  • Joined: 2005/04/04 08:50:32
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/25 00:51:45 (permalink)
+1 (1)
That's good to know as that was one of the several tricks I tried but couldn't get it to work. I guess I'll try it again.
#35
wku
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2018/05/19 02:34:15
  • Location: Poland
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/25 01:52:36 (permalink)
0
Hi
I sent a question to the Microchip engineer. We will see maybe there is any method without using ICD3 :)

strefapic.blogspot.com
#36
Howard Long
Super Member
  • Total Posts : 676
  • Reward points : 0
  • Joined: 2005/04/04 08:50:32
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/25 14:35:33 (permalink)
0
Well I revisited my two bricked devices.
 
For some reason, the first programmed fine without any non standard intervention, so I don't know what I'd done there.
 
The other one, I used the "hold in reset" trick just prior to programming, and that worked.
 
Sometimes, just leaving things for a few days works wonders.
#37
wku
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2018/05/19 02:34:15
  • Location: Poland
  • Status: offline
Re: PIC32MM in Sleep Mode takes 5 mA ??!! 2019/03/26 00:04:32 (permalink)
0
Hi Howard Long
I can put my pic's into the dishwasher, maybe it will work :)

strefapic.blogspot.com
#38
Page: < 12 Showing page 2 of 2
Jump to:
© 2019 APG vNext Commercial Version 4.5