0
\$\begingroup\$

I am using WDT to wake up pic16lf1619 from sleep mode. I have all the unused pins configure as output and connected them with a 10 kohm to the ground. What is happening is that when in sleep, current is about 5mA. I read the data sheet seems to do what is needed, can someone please work me through to solve this?

If by any chance any examples to follow or any article to read to better understand this power consumption issue.

Below is the code that I am using

void main() {

// then, setup OPTION as a first thing to do after each reset
//    OPTION_REG = 0b10001111;          

    OSCCON  = 0b00000000 ;                   // Set the INTOSC= 31KHZ
    FVRCON  = 0x00;
//    ANSELA  = 0x00;              
    CM1CON0 = 0x00;
    CM2CON1 = 0x00;

//    WDTCON0 = 0b00011000;                  // Set the WDT time out to 4 second
    WDTCON0bits.WDTPS1 = 1;

    TRISA   = 0x00;
    TRISB   = 0x00;
    TRISC   = 0x00;
    ODCONA = 1;
//    ODCONB = 1;
//    ODCONC = 1;

//  
//    WPUA   =  0x00;
//    WPUB   =  0x00;
//    WPUC   =  0x00;

// while(OSCSTATbits.LFIOFR==0){};         //wait until LPOSC  is ready

while(1) 
    {   
        CLRWDT();
          RA2 = 1;
//          NOP();
        __delay_ms(5000);
          RA2 = 0;
//          NOP();
        __delay_ms(5000);

       WDTCON0bits.SEN = 1;
        SLEEP();
//        SLEEP();
//        SLEEP();

       WDTCON0bits.SEN = 0;
    }
}
\$\endgroup\$
2
  • 1
    \$\begingroup\$ Are you sure you want them as outputs? High impedance inputs consume less power. \$\endgroup\$
    – Lior Bilia
    Commented May 17, 2018 at 16:02
  • \$\begingroup\$ work me through to solve this? ... solve what? ... you have not said what problem you are facing. \$\endgroup\$
    – jsotola
    Commented May 17, 2018 at 17:31

1 Answer 1

1
\$\begingroup\$

You need to set the PORT bits to zero if you have resistors to ground connected, they are not guaranteed to start up low from reset, and you should set them low explicitly anyway before the MCU goes to sleep.

enter image description here

Also your delay function probably burns up cycles counting, so it's not sleeping for those 10 seconds around the loop, so only sleeping 4 seconds out of 14 (assuming you are actually setting the WDT correctly, which I did not confirm).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.