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

HELP!!RTC + sleep pic16LF1824 consumes more 6mkА [Solved]

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



Joined: 25 Jul 2013
Posts: 17

View user's profile Send private message AIM Address

HELP!!RTC + sleep pic16LF1824 consumes more 6mkА [Solved]
PostPosted: Mon Oct 07, 2013 8:49 am     Reply with quote

Dear developers I develop a real-time correction clock with battery-pic on 16Lf1824.
The microprocessor uses 6mkA. It is 10 times more than it should.What am I doing wrong?
The crystal is connected to the pin timer1. He is value =32768 Hz.
PCWHD compiller 5.011
I am sorry for my English.
Code:
#include <16LF1824.h>
#fuses INTRC_IO,NOWDT,MCLR
#use delay(internal=31khz)

#Byte TMR1H = 0x017   // TIMER1 HIGH BYTE LOOK DATASHEET
#Byte T1CON = 0x018   //TIMER1 CONFIG REGISTER LOOK DATASHEET
#Byte intcon = 0x00B   //TIMER1 CONFIG REGISTER LOOK DATASHEET
#Byte wpua    = 0x20c
#Byte wpuc    = 0x20e
#Byte ANSELA = 0x18c
#Byte ANSELB = 0x18e
#Bit wpua3    = 0x20c.3

#int_TIMER1
void TIMER1_isr()    // 2^16=  65536/2 = 32768 * 1/32.768Hz <--- (1sec)                     
{

   bit_clear(T1CON,7);  //Enable access to the individual bytes of the timer register
   //Bit_Set(TMR1H,7);   //Add 32768 to timer1 by setting high bit or timer register       
   Bit_Set(T1CON,7);   //Disable access to the individual bytes of the timer register
   
   //flg_timer1=true;
   
   output_toggle(PIN_C2);
}



void main()
{   

   wpua=0;
   wpuc=0;
   set_tris_a (4);
   set_tris_c (0);
   output_a (255);
   output_c (255);
   enable_interrupts(INT_TIMER1);
   setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1|T1_ENABLE_T1OSC);
  enable_interrupts(GLOBAL);
   bit_clear(INTCON,0);         
      bit_set(INTCON,3);       
     setup_adc( ADC_OFF );
//   setup_timer_2(T2_DISABLED);
//   setup_timer_6(T6_DISABLED);
//   setup_timer_4(T4_DISABLED);
   setup_ccp1(CCP_OFF);
   setup_ccp2(CCP_OFF);
   setup_ccp3(CCP_OFF);
   setup_ccp4(CCP_OFF);
   setup_spi(SPI_DISABLED);
   setup_vref(VREF_OFF);
   setup_dac(DAC_OFF);
   setup_oscillator(OSC_31KHZ|OSC_INTRC|OSC_PLL_OFF);
 



   sleep();
   
                     
 
 while(true)
   {
   sleep();
   
   }
}
       


Last edited by maxikys on Tue Oct 08, 2013 12:50 am; edited 1 time in total
temtronic



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

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 9:25 am     Reply with quote

What voltage are you using? 5 or 3 ??? That will change power/current used.

What value pullup resistors ?

You're using MCLR, so what pullup resistor is on it?

hth
jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19541

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 9:33 am     Reply with quote

Commonest thing, is if you are using a voltage regulator, _this_ may be drawing the extra power.

All pins on the PIC must be driven. If you have inputs, then the external circuitry needs to ensure the pins are driven high/low. As it stands, you are turning all the pins 'on'. If these are connected to loads, then 'more current'...

Best Wishes
maxikys



Joined: 25 Jul 2013
Posts: 17

View user's profile Send private message AIM Address

PostPosted: Mon Oct 07, 2013 11:34 am     Reply with quote

temtronic wrote:
What voltage are you using? 5 or 3 ??? That will change power/current used.

What value pullup resistors ?

You're using MCLR, so what pullup resistor is on it?

hth
jay

I using 3v. All ports are free, with no external PULLUP and additional load than T1OSI and T1OSO, they oscillator.
As far as I understand # fuses MCLR uses an internal PULLUP.
maxikys



Joined: 25 Jul 2013
Posts: 17

View user's profile Send private message AIM Address

PostPosted: Mon Oct 07, 2013 11:37 am     Reply with quote

Ttelmah wrote:
Commonest thing, is if you are using a voltage regulator, _this_ may be drawing the extra power.

All pins on the PIC must be driven. If you have inputs, then the external circuitry needs to ensure the pins are driven high/low. As it stands, you are turning all the pins 'on'. If these are connected to loads, then 'more current'...

Best Wishes
The circuit is powered from a battery CR2032 3.3 volt. Measure the digital multimeter.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 07, 2013 12:25 pm     Reply with quote

I compiled your program with vs. 5.011 and looked at the fuses at the
end of the .LST file. Look, it's got Brownout enabled by default:
Quote:
Configuration Fuses:
Word 1: 3FC4 INTRC_IO NOWDT PUT MCLR NOPROTECT NOCPD BROWNOUT NOCLKOUT IESO FCMEN
Word 2: 1EFF NOWRT PLL_SW STVREN BORV19 NODEBUG NOLVP

That's guaranteed to use a lot of power (compared to what you want).
Add the NOBROWNOUT fuse to fix this.


Also, with regard to what Ttelmah said about floating pins, you need to
set all unused and unconnected pins to be output pins, and set them low.
Example:
Code:

main()
{
output_low(PIN_C0);
output_low(PIN_C1);
.
.
.
.


}

Or call a routine that does that.


Quote:
#Byte ANSELB = 0x18e

This is a typo in your program. It should be ANSELC. (There is no PortB
on the 16LF1824).
maxikys



Joined: 25 Jul 2013
Posts: 17

View user's profile Send private message AIM Address

PostPosted: Tue Oct 08, 2013 12:04 am     Reply with quote

Thank you very much, especially PCM programmer. PIC consumption decreased to 1 uA, lacks precision instrument trying. Topic can be closed.
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Oct 08, 2013 10:15 am     Reply with quote

maxikys wrote:
Thank you very much, especially PCM programmer. PIC consumption decreased to 1 uA, lacks precision instrument trying. Topic can be closed.


Then go back to top post and edit it to include "[SOLVED]" in the subject line.

you can do it since you are the original post creator.

-Ben

p.s. and consider fixing your "6mkA" to just "6mA" since I don't know what a milli-kilo-Amp is. ;)
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
oxo



Joined: 13 Nov 2012
Posts: 219
Location: France

View user's profile Send private message

PostPosted: Tue Oct 08, 2013 10:30 am     Reply with quote

bkamen wrote:
maxikys wrote:
Thank you very much, especially PCM programmer. PIC consumption decreased to 1 uA, lacks precision instrument trying. Topic can be closed.


Then go back to top post and edit it to include "[SOLVED]" in the subject line.

you can do it since you are the original post creator.

-Ben

p.s. and consider fixing your "6mkA" to just "6mA" since I don't know what a milli-kilo-Amp is. ;)


Yes, except I think he meant 6 microamps
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