2019-07-26 02:08 AM
Hi
Timekeeping in my application is pretty standard: 32 bit unsigned integers which store milliseconds since boot, overflowing every 49 days.
To reduce power consumption, i need a way to wake up from stop mode at a set time in ms. But my device has neither the RTC subsecond or shift control registers. Which leaves me with two options:
Reduce both of the prescalers to make a "second" much shorter, and distort the alarm date to compensate. For example if PREDIV_A = 127 and PREDIV_S = 0, a RTC 'second' will be 3.938 ms. The downside is that the alarm is only about 21 bits wide (28*24*60*60), with such a short 'second', the maximum delay is 2.64 hours (while being 4 ms rough). Also, it is not clear why is the minimum division factor 2 in Cat.1 devices. And haven't been able to find out what happens when the RTC year counter overflows.
The second option is keep the default configuration, and split each wait into two parts: first sleep for the whole second part using an alarm, and then sleep for the remainder using the wakeup timer. But because i cannot read subseconds, it is impossible to wait until a specific time within less than one second, only delays (wait for, not wait until) are possible at such a time scale.
Currently i favor the first option because one spurious wakeup every few hours is better than one on every wait longer than 1 second. Although reducing PREDIV_A lower than 127 (to get better precision) "may increase power consumption", but then again, so will running longer because the MCU cannot wake up exactly on time for an event.
2019-07-28 04:40 AM
What about syncing your 32 bit ms counter with the RTC second on startup. Now when you sleep and the RTC wakes you up, you set the 32 bit ms counter to a full second. Now wait for the remaining time with the normal mechanism.
2019-07-28 06:23 AM
With a hardware timer running, i can only go down to low power sleep mode, which consumes more power than stop mode, but it would only be active for at most 1 s. Which I guess it isn't that bad. Any thoughts on speeding up the RTC 'second'?
2019-07-28 07:19 AM
Can you perhaps stop the 32 bit ms counter before going to sleep and set a new, corrected value when RTC wakes up?
2019-07-28 07:30 AM
Yes, but how can i wake up from stop mode with ms accuracy? Waking up on the whole second and then waiting the rest in some higher power mode would work, but there should be a better way.
2019-07-28 09:03 AM
Why don't you simply use a non-Cat1 'L15x?
JW
2019-07-28 10:56 AM
I already do, in the next version of my design, but i want to work out any low power issues before finishing the respin.
2019-07-28 12:27 PM
Aren't the -A versions drop-in replacements? (I genuinely don't know, I was under the impression they are). That would mean just swapping the mcu. It's not a BGA, is it?
JW