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 support@ccsinfo.com

PIC18LF25K40 Sleep Mode High Current Problem

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



Joined: 06 Oct 2020
Posts: 9

View user's profile Send private message AIM Address

PIC18LF25K40 Sleep Mode High Current Problem
PostPosted: Wed Oct 07, 2020 7:37 am     Reply with quote

Hi!

In my project, in the sleep mode part, I applied everything for the extreme low-power I applied everything same as the datasheet.(You can see this part below.)
Although I have applied the same things, I drew very very very high current in the sleep mode.

My CCS C İDE 5.0089.

eXtreme Low-Power (XLP) Features
• Sleep mode: 50 nA @ 1.8V, typical
• Windowed Watchdog Timer: 500 nA @ 1.8V, typical
• Secondary Oscillator: 500 nA @ 32 kHz
• Operating Current:
– 8 uA @ 32 kHz, 1.8V, typical
– 32 uA/MHz @ 1.8V, typical


My project code is:
Code:

#include <18LF25K40.h>            //PIC 8bits
#device ADC=10
#use delay(internal=4000000)


#FUSES PUT                     
#FUSES PROTECT                 
#FUSES NODEBUG                 
#FUSES NOBROWNOUT               
#FUSES NOLVP                   
#FUSES NOCPD                   
#FUSES NOWRT
#FUSES NOMCLR                 
#fuses NOEXTOSC
#fuses RSTOSC_LFINTRC
#FUSES NOCLKOUT
#FUSES NOMCLR


void main(){

 
   setup_oscillator(OSC_HFINTRC_4MHZ|OSC_HFINTRC_ENABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(T0_OFF);
   setup_timer_1(T1_DISABLED);   
   setup_timer_2(T2_DISABLED,0,1);
   setup_ccp1(CCP_OFF);
//setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_XMIT_L_TO_H|SPI_CLK_DIV_4 );

   while(true)
   {

 delay_ms(10);
 sleep(SLEEP_FULL);
 
  }

}



If you have any ideas for this problem, please tell me.
_________________
software electronic development
Ttelmah



Joined: 11 Mar 2010
Posts: 19260

View user's profile Send private message

PostPosted: Wed Oct 07, 2020 8:18 am     Reply with quote

First little thing:

setup_spi(SPI_SS_DISABLED);

Wrong. This enables the SPI, with slave select disabled. To disable the
SPI just use

setup_spi(FALSE);

Then what is driving the PIC pins?.
No pin should ever be left floating. They must all be either pulled up/down
externally to the chip, or driven high/low by the PIC. Each floating pin,
depending on how much RF noise is around the chip can/will result in uA
more current being drawn. The pins must (obviously) be driving in the
direction that turns things 'off'.

Then the low power mode requires clocking off the low frequency
oscillator, not the 4MHz oscillator. Before sleeping, you need to
switch to this oscillator, and then switch back to the 4MHz oscillator
when you wake.

Then the XLP figure quoted is with everything turned off. You have the
WDT running, so this draws extra power etc. etc..
gaugeguy



Joined: 05 Apr 2011
Posts: 290

View user's profile Send private message

PostPosted: Wed Oct 07, 2020 9:24 am     Reply with quote

I don't see where you show your supply voltage, measured current, method of measuring current, and power supply type.
Ttelmah



Joined: 11 Mar 2010
Posts: 19260

View user's profile Send private message

PostPosted: Thu Oct 08, 2020 12:55 am     Reply with quote

and (of course), the old common 'classic', reading current from a supply
that has a voltage regulator feeding the PIC. A typical Vreg, will often
draw several mA itself.....
azmi42



Joined: 06 Oct 2020
Posts: 9

View user's profile Send private message AIM Address

PIC18LF25K40 Sleep Mode High Current Problem
PostPosted: Thu Oct 08, 2020 2:29 am     Reply with quote

gaugeguy wrote:
I don't see where you show your supply voltage, measured current, method of measuring current, and power supply type.



With the same measurement technique, 18f45k20 draws 1.5 uA in sleep mode with two batteries but 18f25k40, 18F25Q10 draws 0.475uA ~ 0.500 uA in sleep mode
_________________
software electronic development
azmi42



Joined: 06 Oct 2020
Posts: 9

View user's profile Send private message AIM Address

PIC18LF25K40 Sleep Mode High Current Problem
PostPosted: Thu Oct 08, 2020 2:31 am     Reply with quote

Ttelmah wrote:
First little thing:

setup_spi(SPI_SS_DISABLED);

Wrong. This enables the SPI, with slave select disabled. To disable the
SPI just use

setup_spi(FALSE);

Then what is driving the PIC pins?.
No pin should ever be left floating. They must all be either pulled up/down
externally to the chip, or driven high/low by the PIC. Each floating pin,
depending on how much RF noise is around the chip can/will result in uA
more current being drawn. The pins must (obviously) be driving in the
direction that turns things 'off'.

Then the low power mode requires clocking off the low frequency
oscillator, not the 4MHz oscillator. Before sleeping, you need to
switch to this oscillator, and then switch back to the 4MHz oscillator
when you wake.

Then the XLP figure quoted is with everything turned off. You have the
WDT running, so this draws extra power etc. etc..



Code:
#include <18LF25K40.h>            //PIC 8bits
#device ADC=10
#use delay(internal=4000000)


#FUSES PUT                     
#FUSES PROTECT                 
#FUSES NODEBUG                 
#FUSES NOBROWNOUT               
#FUSES NOLVP                   
#FUSES NOCPD                   
#FUSES NOWRT
#FUSES NOMCLR                 
#fuses NOEXTOSC
#FUSES NOCLKOUT
#FUSES NOMCLR


void main(){

   setup_oscillator(OSC_SOSC) ;
   setup_timer_0(T0_OFF);
   setup_timer_1(T1_DISABLED);   
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED); 
   setup_timer_4(T4_DISABLED,0,1);
   setup_timer_5(T5_DISABLED);
   setup_timer_6(T6_DISABLED,0,1);
   setup_vref(FALSE);
   setup_ccp1(CCP_OFF);
   setup_dac(DAC_OFF);
   SETUP_ADC(ADC_OFF);
   SETUP_ADC_PORTS(NO_ANALOGS);
   DISABLE_INTERRUPTS(GLOBAL);
   setup_spi(SPI_DISABLED );
   
set_tris_a(0x00);
set_tris_b(0x00);
set_tris_c(0x00);
set_tris_e(0x00);

OUTPUT_a(0x00);
OUTPUT_b(0x00);
OUTPUT_c(0x00);
OUTPUT_e(0x00);


   while(true)
   {

DELAY_MS(100);

SLEEP(SLEEP_FULL);


  }

}



peripheral pins I turned everything off but the result has not changed where am I making a mistake?

Why 18f25k40 and 18f25q10 have problems while 1845k20 is no problem
_________________
software electronic development


Last edited by azmi42 on Thu Oct 08, 2020 4:49 am; edited 1 time in total
azmi42



Joined: 06 Oct 2020
Posts: 9

View user's profile Send private message AIM Address

PostPosted: Thu Oct 08, 2020 2:33 am     Reply with quote

Ttelmah wrote:
and (of course), the old common 'classic', reading current from a supply
that has a voltage regulator feeding the PIC. A typical Vreg, will often
draw several mA itself.....



I feed directly with 2 alcaline cell batteries at 3.2 volts.
_________________
software electronic development
Ttelmah



Joined: 11 Mar 2010
Posts: 19260

View user's profile Send private message

PostPosted: Thu Oct 08, 2020 3:33 am     Reply with quote

You still haven't turned the clock rate down.
azmi42



Joined: 06 Oct 2020
Posts: 9

View user's profile Send private message AIM Address

PostPosted: Thu Oct 08, 2020 4:04 am     Reply with quote

Ttelmah wrote:
You still haven't turned the clock rate down.


I set the oscillator clock at 32khz and tried many assumptions but the lowest I saw is 180 uA@1.8 uA

PIC18F45K20 current draw in 4Mhz oscillator 1.5uA @ 3.2v
4Mhz oscillator PIC18F25K40 current draw 500uA @ 3.2v
Where am I doing wrong I could not find :(
_________________
software electronic development
gaugeguy



Joined: 05 Apr 2011
Posts: 290

View user's profile Send private message

PostPosted: Thu Oct 08, 2020 6:19 am     Reply with quote

Quote:
With the same measurement technique, 18f45k20 draws 1.5 uA in sleep mode with two batteries but 18f25k40, 18F25Q10 draws 0.475uA ~ 0.500 uA in sleep mode


It would seem from the above statement the k40 draws 1/3 the current that the k20 does.

If the above units are incorrect and you were drawing 0.5mA (instead of uA) then I suspect you are not staying in sleep. Something is waking the processor from sleep shortly after you enter. It may be the watchdog timer or another peripheral.
Set a pin high (or turn an LED on) at the beginning of your delay_ms(100) statement and then set it low at the end. Activity on this pin will determine if it is staying in sleep or not.
Ttelmah



Joined: 11 Mar 2010
Posts: 19260

View user's profile Send private message

PostPosted: Thu Oct 08, 2020 6:27 am     Reply with quote

One big difference is the default watchdog period is much faster on this chip.
Just 1mSec. Since the watchdog is not being reset anywhere, it'll be
rebooting on the watchdog, before the sleep is ever reached....
temtronic



Joined: 01 Jul 2010
Posts: 9134
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Oct 08, 2020 6:33 am     Reply with quote

re:
Quote:
I drew very very very high current in the sleep mode.

I must be ANCIENT....as I don't see 1.5 microamps as being 'very,very high current'. Smile

I would though, put a recording scope/meter on to measure actual curent being drawn for say 1/2-1 hr period, then playback the events to see if current is steady or 'pulses'. My guess is 'something' is waking up the PIC.
Ttelmah



Joined: 11 Mar 2010
Posts: 19260

View user's profile Send private message

PostPosted: Thu Oct 08, 2020 6:45 am     Reply with quote

I don't think it ever reaches the sleep.
Default 1mSec. 500mSec delay. Result, reset before the sleep is reached...
azmi42



Joined: 06 Oct 2020
Posts: 9

View user's profile Send private message AIM Address

PostPosted: Sat Oct 10, 2020 7:24 am     Reply with quote

Ttelmah wrote:
One big difference is the default watchdog period is much faster on this chip.
Just 1mSec. Since the watchdog is not being reset anywhere, it'll be
rebooting on the watchdog, before the sleep is ever reached....


Thank you so much I have solved the problem 😊
_________________
software electronic development
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