STM32F100RBT Avoiding RTC Time Race When Setting Alarm For 1 Second
Hello,
I have a system using STM32F100RBT needs wake up from standby mode every second.
Some operations it conducts when it wakes might take longer than a second.
Each time before going to sleep, I read the current RTC time, and set an alarm for this time + 1 second.
The problem is that the RTC resolution is 1 second, and this is also the interval I'm waiting.
I need to avoid a time race, where an RTC second increases just between reading the RTC and going to standby.
One option is, assuming the system won't be awake longer than an hour, to use the systick milliseconds, and be stuck in a busy-wait before reading the RTC, if (systick % 1000 > 990) (having a 10ms buffer).
This will work only if I'm guaranteed that the systick starts ticking the moment RTC reaches a full second (or with a small, but constant delay, without an accumulating error).
- Do I have this guarantee about systick? (something I would like to know regardless, as doing black-boxtests might give me a false positive)
- Any other recommended way to deal with this?
Thanks!