2020-11-09 12:00 AM
I want to calculate the actual time the CPU spends in STOP2 mode.
I wake up the MCU either by RTC Alert or LPUART.
The issue is more relevant to LPUART wake use case, because it could happen before the RTC alert expires.
I'm using RTC with LSI which continues to work in low power modes.
Is there a proper way to save the RTC time before and after entering the stop mode?
The RTC is configured to scale from 488 µs to 32s.
So I want the timestamp calculation to support both milliseconds and seconds.
How can I achieve that?
Thanks All!!!
2020-11-10 06:32 AM
What about using the LP-Timer?
2020-11-10 08:23 AM
Yes I'm using a battery.
2020-11-10 12:02 PM
Good idea.
JW
2020-11-18 05:45 AM
This the calculation I'm using:
int duration = (int)((int)rtcStart.SubSeconds-(int)rtcEnd.SubSeconds)*1000;
duration = ((int)rtcEnd.Seconds-(int)rtcStart.Seconds)*1000+duration/(int)rtcEnd.SecondFraction;
looks like it works.