STM32F100RB Clock Skew In RTC and HAL_GetTick
Hello, all.
I'm using the STM32F100RB , mounted on the STM32VL Discovery board.
The clock confioguration, done in STM32CUBEMX is supplied at the end of the post.
I wanted to use HAL_GetTick to get approximate millisecond resolution for the RTC.
After some tests, I noticed clock skews, so I ran a test for 1000 RTC seconds. (during which I constattly polled HAL_RTC_GetTime and HAL_RTC_GetDate).
These are the times I discovered:
Actual Time: 1,009,129 ms
RTC Time: 1,000 s
HAL_GetTick Time: 1,009,217 ms
So while the HAL_GetTick was pretty close (but still has a sizeable skew of almost 100 ms after 1000 seconds, which is 8.6 seconds a day), The RTC was way off, accumulating a deficit of 9 seconds in that span.
So, I have 3 questions:
- How do I fix the RTC clock skew?
- How do I fix the HAL_GetTick clock skew?
- IS there a better way to calculate milliseconds for RTC?
The STM32CUBEMX Clock Configuration. is attached below.
Thanks in advance!
