You don't tell us what your hardware configuration is. You do not appear to be setting TRIS for ports A, C and E. They will probably have defaulted to inputs and if any are floating they can be in an undefined state and drawing high current. Make sure all unused inputs are tied high or low and are not allowed to float some mid voltage where the CMOS inputs draw high current.
Better to make all unused pins outputs and force them high or low as appropriate for your hardware.
Also, when the system goes to sleep, the high/low status of any outputs are preserved. You might find the processor is asleep but a pin is high and sourcing current to a load like your buzzer. Piezo buzzers can have high leakage. Equally the pin might be low and sinking current from the supply. Use a voltmeter and check that all i/o pins are doing exactly what you want. The WatchDog, brownout and other timers and peripherals all draw additional current and the datasheet gives the most favourable sleep current with all these devices turned off.
I find it helpful to explicitly define every hardware pin on all ports, whether used or not, with something like
PBP assumes the WatchDog prescaler is set to 512. SLEEP xx is only accurate if the WDTPS is 512. SLEEP causes a fairly high current spike each time the chip wakes up, approximately once per second. If you set the WDTPS to something like 2048 the sleep times are off by a factor of 4 but the wakeup current spike is reduced in frequency by a factor of 4 as well.Code:'PortA AccelY var porta.0 ' accelerometer Y axis AccelX var porta.1 ' accelerometer X axis ECG var porta.2 ' analog heart input MemD var porta.3 ' M25Pxx Data TO memchip MemClk var porta.4 ' M25Pxx clock LED var porta.5 ' Active HIGH SpareA6 var porta.6 ' SpareA7 var porta.7 ' TRISA = %00001111 ' lowest power PORTA = %00000000 ' lowest power
Getting down to lowest power is hard and needs a sensitive microammeter in my experience. I have spent months getting to minimum current on a data logger and have now got a system down below 500 nA with a PIC18F4620 at 3.7 volts. That includes 256 Mbits of memory and all peripherals.
HTH
BrianT
Last edited by BrianT; - 15th November 2009 at 01:05. Reason: [code] ..... [/code]
I DID THIS SETTING BUT STILL 5mA IN SLEEP MODE [ @ SLEEP @ NOP]Code:Include "modedefs.bas" @ DEVICE WDT_OFF, PWRT_OFF,MCLR_OFF,CPD_OFF'IESO_OFF PCON.4 = 1 WDTCON.0 = 0 WDTCON.4 = 3 OPTION_REG = %00000001 ADCON0 = 0 OSCCON.6 = 7 intcon = 0 vrcon = 0 PORTB =%00000001 PORTA = 0 PORTC = 0 TRISA = 0 TRISC = 0 TRISB = %00000001
...try to add:
CMCON0.2 = 1 'Comparators Off for PORTA.0 to 3 (CM bits)=save power
CMCON0.1 = 1
CMCON0.0 = 1
VRCON.7 = 0 'CVref circuit powered down (VREN bit)=save power
I DID THIS BUT STILL 5mA IN SLEEP MODECode:@ DEVICE WDT_OFF, PWRT_OFF,MCLR_OFF,CPD_OFF VRCON.7 = 0 CMCON0=%00000111 WDTCON.0 = 0 WDTCON.4 = 3 OPTION_REG.7 = 0 ADCON0.0 = 0 OSCCON.6 = 7 LCDCON.4=0 LCDCON.6=1 LCDCON.7=0 'CMCON = 7 intcon = 0![]()
Last edited by Mus.me; - 15th November 2009 at 05:32.
Hi there,
Any changes that you could share applications schematics with us?
Do you have discrete pull-ups or pull-downs connected to PIC IO's?
Is PIC only active part of the system?
BR,
-Gusse-
Bookmarks