Does LowPower Shutdown() reset the internal RTC?

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

Does LowPower Shutdown() reset the internal RTC?

Post 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?
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

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

Post 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?
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

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

Post 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).
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

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

Post 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
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

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

Post by Bambo »

Oh nice! thanks :)
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

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

Post 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?
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

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

Post by fpiSTM »

Your code is not complete..

where is setup() ? where ready() is called ? and mainly which board you used ?
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

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

Post 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.
Bambo
Posts: 75
Joined: Wed Jan 15, 2020 8:36 pm

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

Post 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 :)
Post Reply

Return to “General discussion”