View previous topic :: View next topic |
Author |
Message |
maxikys
Joined: 25 Jul 2013 Posts: 17
|
HELP!!RTC + sleep pic16LF1824 consumes more 6mkА [Solved] |
Posted: Mon Oct 07, 2013 8:49 am |
|
|
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: 9226 Location: Greensville,Ontario
|
|
Posted: Mon Oct 07, 2013 9:25 am |
|
|
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: 19515
|
|
Posted: Mon Oct 07, 2013 9:33 am |
|
|
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
|
|
Posted: Mon Oct 07, 2013 11:34 am |
|
|
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
|
|
Posted: Mon Oct 07, 2013 11:37 am |
|
|
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
|
|
Posted: Mon Oct 07, 2013 12:25 pm |
|
|
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
|
|
Posted: Tue Oct 08, 2013 12:04 am |
|
|
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
|
|
Posted: Tue Oct 08, 2013 10:15 am |
|
|
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
|
|
Posted: Tue Oct 08, 2013 10:30 am |
|
|
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 |
|
|
|