cancel
Showing results for 
Search instead for 
Did you mean: 

STM systick counter

leon23
Associate II
Posted on July 31, 2012 at 06:55

I am trying to use systick counter to verify the accuracy of my RTC. Bascially what I did is check the systick counter against RTC timer in the second interrupt. I find it seems the systick count is heavily affected by other interrupts and not accurate. In the end I changed to use DWT cycle count and the result is fairly good and stable. Here my question is how the Systick counter is updated (I'm fairly new to embedded development)? I thought it is not driven by interrupt. The reason I thought like this is if I use TIMX and don't enable its interrupt. The counter of TIMX is pretty accurate.

3 REPLIES 3
Posted on July 31, 2012 at 13:08

SysTick clocks a 24-bit counter at SYSCLK/HCLK div 8, generates an interrupt at expiration, and restarts. Good for periodic stuff.

Depending on STM32 series, some have RTC LSI/LSE tied to a TIM so period of RTC can be measured explicitly via specific TIMCLK and prescaler. LSI typically not  very stable, depending on series some 39-40 KHz, dependent on voltage and temperature. If you want something more stable us a 32 KHz external watch crystal for LSE.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on February 19, 2018 at 13:25

Hi Clive, i've a similar problem: i want to verify the accuracy of my hardware RTC with an external LSE at 32768Hz (STM32L4) using the Systick.

I create a Timer with an interrupt every 1s. In its Interrupt_Handler i read simultaneously the HAL_Tick and the Timestamp (from the RTC). The result i've obtained is:

   - the difference between each interrupt from the Hal_tick was fixed at 1000ms,

   - while fot RTC it varied between 980,1020 ms.

Which is correct? The sys_tick or the RTC ?

Thank you

Posted on February 19, 2018 at 13:44

'

Which is correct? The sys_tick or the RTC ?'

both are accurate. RTCs don't increment fast -> to conserve energy, as those guys are designed to keep long-term timing accurate.

as the two are asynchronous, and with bigger stepping difference, what you observed can happen.