LowPowerLab Forum

Hardware support => Low Power Techniques => Topic started by: jhoward88 on April 29, 2020, 03:29:59 PM

Title: watchdog interaction with sleep
Post by: jhoward88 on April 29, 2020, 03:29:59 PM
I'm using something like this and getting more reboots than I should.  I suspect something is not ok about using wdt disable/enable cycles like this.
Can anyone give me some advice on it?

Code: [Select]
void loop() {
    wdt_enable(WDTO_8S);   

    if(pinChangeInterruptFlag) {   // we can get interrupted any time, but mostly just 8 second sleeps and wakes
       do_small_stuff()   //takes a couple of seconds

       if (extraStuffNeeded ){     //happens sometimes. uh oh, this might take 6 seconds...
    wdt_disable();         // so lets give ourselves another 8
    wdt_enable(WDTO_8S);
    go_do_extra stuff();
    }
    }


    wdt_disable();
    radio.sleep();   
    LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
}

Thanks,
Jerry
Title: Re: watchdog interaction with sleep
Post by: TomWS on May 01, 2020, 07:55:20 PM
I'm thinking you didn't post all of the code so hard to tell what's wrong.