Page 1 of 1

Does LowPower Shutdown() reset the internal RTC?

Posted: Tue Apr 14, 2020 1:56 pm
by Bambo
Hi, i am looking to save power using the shutdown LowPower function but i'm not sure what is preserved after the shutdown. If i configure the RTC, then trigger a LowPower shutdown, will the RTC reset?

Re: Does LowPower Shutdown() reset the internal RTC?

Posted: Tue Apr 14, 2020 2:50 pm
by Bambo
Also, what's the point in having a LowPower shutdown() and also having an IWatchdog, don't they do exactly the same thing?

Re: Does LowPower Shutdown() reset the internal RTC?

Posted: Tue Apr 14, 2020 4:19 pm
by Bambo
So there isn't much difference between rebooting using the LowPower.shutdown() and the IWatchdog methods other than with the LowPower module, you can specify an amount of time to stay shutdown for (i think, i'm just testing this).

Re: Does LowPower Shutdown() reset the internal RTC?

Posted: Tue Apr 14, 2020 4:51 pm
by fpiSTM
For RTC you can handle the reset if you want:
https://github.com/stm32duino/STM32RTC# ... rsion--150

IWatchdog and shutdown have not the same behavior:
https://github.com/stm32duino/Arduino_C ... /README.md

Re: Does LowPower Shutdown() reset the internal RTC?

Posted: Fri Apr 17, 2020 9:58 am
by Bambo
Oh nice! thanks :)

Re: Does LowPower Shutdown() reset the internal RTC?

Posted: Fri Apr 17, 2020 11:05 am
by Bambo
On my test bench, the LowPower.shutdown() reboot causes the rtc.isTimeSet() to return false even if it was preivously set? Am i doing something logically wrong here?

Code: Select all


void AlarmFunc(void* data)
{
    Serial3.println("Woke");
    Serial3.flush();
}

void ready()
{
    STM32RTC& rtc = STM32RTC::getInstance();
    rtc.begin();

    if (rtc.isTimeSet())
    {
        Serial3.println("RTC is set!");
        Serial3.flush();
    }
    else
    {
        Serial3.println("RTC is not set... setting");
        Serial3.flush();
        rtc.setEpoch(1587119789U);
    }

    delay(1000);

    // reboot.
    LowPower.begin();
    LowPower.enableWakeupFrom(&rtc, AlarmFunc, nullptr);
    LowPower.shutdown(2000);
}

void loop()
{
}

Output:
12:03:41.205 -> RTC is not set... setting
12:03:54.345 -> RTC is not set... setting


Edit:
The LowPower.shutdown() function does wipe the RTC, however, when i use LowPower.deepSleep() the RTCis preserved.

Is LowPower.shutdown() ment to wipe the RTC?

Re: Does LowPower Shutdown() reset the internal RTC?

Posted: Fri Apr 17, 2020 2:24 pm
by fpiSTM
Your code is not complete..

where is setup() ? where ready() is called ? and mainly which board you used ?

Re: Does LowPower Shutdown() reset the internal RTC?

Posted: Fri Apr 17, 2020 2:38 pm
by fpiSTM
I guess you work on L4, in shutdown mode use the LSE:

Code: Select all

  rtc.setClockSource(STM32RTC::LSE_CLOCK);
before the rtc.begin.

Re: Does LowPower Shutdown() reset the internal RTC?

Posted: Fri Apr 17, 2020 2:45 pm
by Bambo
Nice! thanks, yes this is custom code, i made a system that does POST checking and calls this Ready() when its done. Thanks for debugging i will test it :)