|
|
View previous topic :: View next topic |
Author |
Message |
mahdihir
Joined: 01 Dec 2013 Posts: 7 Location: Iran
|
how to set LP mode for 12f683 |
Posted: Sun Dec 01, 2013 10:15 pm |
|
|
In datasheet mention that 12f683 use 11uA in LP mode.
I tried to get this value but couldn't get less than 115uA, this is very important issue for battery life.
Anyone can help me,
the code as below:
Code: |
#include <12F683.h>
#device ADC=10
#fuses LP, INTRC_IO,NOWDT,NOPUT,NOPROTECT,NOCPD,NOMCLR
#use delay(INTERNAL=32000)
#define GP0 PIN_A0
#define GP1 PIN_A1
#define GP2 PIN_A2
#define GP3 PIN_A3
#define GP4 PIN_A4
#define GP5 PIN_A5
int16 i, value, min, max, j;
void init()
{
set_tris_a( 0b00000001 ); // set GP0 input, GP1 output, GP2 output, GP3 output GP4 output, GP5 output
setup_comparator( NC_NC_NC_NC ); // disable comparators
setup_adc_ports( AN0_ANALOG ); // enable analog inputs
setup_adc(ADC_CLOCK_INTERNAL); // Built-in A/D setup function
set_adc_channel(0); // Built-in A/D setup function
value = read_adc();
}
void main()
{
init();
output_low( GP3 ); // set low
output_low( GP5 ); // set low
setup_adc_ports(sAN0);
setup_adc(ADC_CLOCK_DIV_4);
min =23;
max =23;
j=0;
//////////////////////////////////////////////test adc/////////////////////////////////
loop0:
output_low(PIN_A2);
while(TRUE)
{
j++;
i=0;
output_high (PIN_A1);
// output_high (PIN_A4);
value=0;
delay_ms(50);
value = read_adc();
delay_ms(50);
if(value<min)
{
goto loop1;
}
output_low(PIN_A1);
//output_low(PIN_A4);
delay_ms(2500);
}
goto loop2;
///////////////////////////,..////////////////////////conter//////////////////////////////////
loop1:
output_low(PIN_A1);
for(i=0; i<=2; ++i) {
j++;
value=0;
output_high (PIN_A4);
// output_high (PIN_A2);
value = read_adc();
if(value>min)
{
goto loop0;
}
delay_ms(50);
output_low(PIN_A4);
// output_low(PIN_A2);
delay_ms(2500);
}
value=0;
output_high (PIN_A1);
delay_ms(100);
value = read_adc();
output_low(PIN_A4);
if(value>min)
{
goto loop0;
}
//////////////////////////////////////////////////////////////////error condition///////////////////////////////////
setup_adc(ADC_OFF);
while (TRUE)
{
output_low(PIN_A1);
delay_ms(1000);
output_high (PIN_A2);
delay_ms(50);
output_low(PIN_A2);
}
/////////////////////////////////////////////////////////////////////expire battery////////////////////////////////////////
loop2:
setup_adc(ADC_OFF);
while (TRUE)
{
output_low(PIN_A1);
delay_ms(2000);
output_high (PIN_A2);
delay_ms(50);
output_low(PIN_A2);
}
} |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Dec 02, 2013 12:32 am |
|
|
Quote: | #fuses LP, INTRC_IO,NOWDT,NOPUT,NOPROTECT,NOCPD,NOMCLR
#use delay(INTERNAL=32000) |
Read the PIC data sheet. Use only one oscillator fuse. The compiler
will use the last one, if you type in more than one. In this case, it
will use INTRC_IO. Also read the frequencies that are available for
INTRC_IO in the data sheet.
Quote: | I tried to get this value but couldn't get less than 115uA | Read this thread about the Brownout fuse:
http://www.ccsinfo.com/forum/viewtopic.php?t=51293 |
|
|
jgschmidt
Joined: 03 Dec 2008 Posts: 184 Location: Gresham, OR USA
|
|
Posted: Mon Dec 02, 2013 5:41 pm |
|
|
You might consider looking at the 12LF1840. It's pin compatible and I have some applications running at just a few uA. Sleep is at less than 0.1uA. You still have to pay attention to configuration and setting of unused pins. I used the 683 as my all-around general purpose processor for many years - the 1840 is my replacement for it. Faster, less power and added features like the Data Signal Modulator. _________________ Jürgen
www.jgscraft.com |
|
|
|
|
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
|