CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Pic24 can't reach low power spec.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Eugeneo



Joined: 30 Aug 2005
Posts: 155
Location: Calgary, AB

View user's profile Send private message

Pic24 can't reach low power spec.
PostPosted: Sat Nov 14, 2015 5:46 pm     Reply with quote

Hi all,

Been trying to setup this Pic (24FJ128GC006) to sip as little power as possible. When the mcu enters sleep without RAM retention, I measure 75 uA - which is fine as a baseline. When it is running at 32K LPRC, it consumes 330 uA. Based on the datasheet, it should be closer to +80uA from my baseline.

All the Peripheral Module Disables (PMD) have been set - this helped a little but there is still about 175uA that haven't been accounted for.

I've tried many things with no success. Any help is appreciated.







Here's the code:

Code:


#include <24FJ128GC006.h>
 
#use delay(internal = 32767)

#FUSES NOWDT                     //No Watch Dog Timer
#FUSES NOWRT                     //Program memory not write protected
#FUSES NOPROTECT                 //Code not protected from reading
#FUSES NOJTAG                    //JTAG disabled
#FUSES NODEBUG                   //No Debug mode for ICD
#FUSES ICSP1                     //ICD uses PGC1/PGD1 pins
#FUSES NOIESO                    //No Internal External Switch Over mode enabled
#fuses NODSWDT                   //Deep Sleep Watchdog Timer disabled
#FUSES NOBROWNOUT                //No brownout reset
#FUSES NOJTAG                    //JTAG disabled

#fuses OSCIO                     //OSC2 is general purpose output
#fuses NORTCBAT                  //RTC operation is discontinued in VBAT

#fuses NOPR                      //Pimary oscillator disabled
#fuses LPRC                      //Internal low power RC Oscillator

#build(STACK = 0x400)

#define LED1 PIN_D10      // upper right output
#define led_on output_low(led1)
#define led_off output_high(led1)

#define TEST_FLASH {led_on; delay_ms(200); led_off; delay_ms(200);}
#define stop do{}while(1)
#define flash do{test_flash;}while(1)

/****************************************************************************
 * Main app
 ****************************************************************************/
void Main(void) {

output_low(PIN_B7);     // PGM
output_low(PIN_B6);     // CLK
output_low(PIN_B5);
output_low(PIN_B4);
output_low(PIN_B3);
output_low(PIN_B2);
output_low(PIN_B1);
output_low(PIN_B0);

output_low(PIN_B12);
output_low(PIN_B13);
output_low(PIN_B14);
output_low(PIN_B15);


output_low(PIN_G9);
output_low(PIN_G8);
output_low(PIN_G7);
output_low(PIN_G6);

output_low(PIN_G2);
output_low(PIN_G3);

output_low(PIN_E0);
output_low(PIN_E1);
output_low(PIN_E2);
output_low(PIN_E3);
output_low(PIN_E4);


output_low(PIN_E5);
output_low(PIN_E6);
output_low(PIN_E7);


output_low(PIN_F3);
output_low(PIN_F4);     // SP2
output_low(PIN_F5);     // SP2


output_low(PIN_D0);
output_low(PIN_D1);     // SP1
output_low(PIN_D2);     // SP1
output_low(PIN_D3);
output_low(PIN_D4);
output_low(PIN_D5);
output_low(PIN_D6);
output_low(PIN_D7);
output_low(PIN_D8);
output_low(PIN_D9);
//output_low(PIN_D10);  // LED
output_low(PIN_D11);

output_float(PIN_C13);
output_float(PIN_C14);


#byte PMD1 = getenv("byte:PMD1")
#byte PMD2 = getenv("byte:PMD2")
#byte PMD3 = getenv("byte:PMD3")
#byte PMD4 = getenv("byte:PMD4")
#byte PMD5 = getenv("byte:PMD5")
#byte PMD6 = getenv("byte:PMD6")
#byte PMD7 = getenv("byte:PMD7")


PMD1 = 0xFF;
PMD2 = 0xFF;
PMD3 = 0xFF;
PMD4 = 0xFF;
PMD5 = 0xFF;
PMD6 = 0xFF;
PMD7 = 0xFF;

do
   {
   delay_ms(2000);
   TEST_FLASH
   } while(1);
}


Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Sun Nov 15, 2015 9:50 am     Reply with quote

You are running off the FRC oscillator, not the LPRC oscillator.....
Eugeneo



Joined: 30 Aug 2005
Posts: 155
Location: Calgary, AB

View user's profile Send private message

PostPosted: Sun Nov 15, 2015 5:33 pm     Reply with quote

Thanks Ttelmah,

If I insert this line at the beginning, the current draw is 224 uA

Code:

setup_oscillator(OSC_RC, 0);



And this one uses the FRC and draws 500 uA
Code:

setup_oscillator(OSC_INTERNAL, 32768);


Still on the high side. Time to strip down the hardware to see where the extra is.
Eugeneo



Joined: 30 Aug 2005
Posts: 155
Location: Calgary, AB

View user's profile Send private message

PostPosted: Sun Nov 15, 2015 6:03 pm     Reply with quote

All the hardware is removed. The unit now draws a total of 13 uA Very Happy in deep sleep mode with the LPRC waking the unit up every second. When the MCU wakes up, it draws 284 uA. Does anybody know how I can test if it is running off the LPRC?

Thanks for the help.

** EDIT: If I bring the source voltage from 3.3v to 2.0v, the unit still runs and draws 72 uA. Interestingly enough, the datasheet shows very little linear change between 3.3v and 2.0v (Param# DC31). Is there any additional on chip regulators that need to be disabled via bit?
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Mon Nov 16, 2015 2:29 am     Reply with quote

I know on some compiler versions/chips, CCS 'silently' switches oscillators based on the clock speed you select. The LPRC, is specified as 31KHz. On these you get the different oscillators, by selecting:

#use delay(internal = 31000) //LPRC

or

#use delay(internal = 32500) //FRC

So worth trying specifying the frequency for LPRC.

The easiest way to 'know' what is selected, is simply look at the end of the .lst file and how the fuses are set.

Question. How is Vbus3v3 connected? This needs to connect to Vdd. Quote from data sheet:
"Connecting VBUS3V3 to VDD is highly recommended, as floating this input can cause increased IPD currents.".

Could be your problem.
Eugeneo



Joined: 30 Aug 2005
Posts: 155
Location: Calgary, AB

View user's profile Send private message

PostPosted: Mon Nov 16, 2015 11:35 am     Reply with quote

I found this link. It allows you to modify the clock source input with the required ASM unlock sequence. It will allow you to manually adjust and verify the clock sources. Note: Please be aware, the multiplier entry doesn't work on this specific Pic.

//http://www.ccsinfo.com/forum/viewtopic.php?t=53502&highlight=pic24+setuposcillator2

As you said, based on the values, the compiler decides to select between LPRC, LPFRC, FRC.

#use delay(internal = 31000) //LPRC
#use delay(internal = 32500) //FRC

setup_oscillator(OSC_INTERNAL, 31250);
setup_oscillator(OSC_INTERNAL, 31000);
setup_oscillator(OSC_INTERNAL, 500000);
setup_oscillator(OSC_INTERNAL, 8000000, 4);


Thanks for also pointing out the VBUS3V3 recommendation! I'm going to try this.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group