cancel
Showing results for 
Search instead for 
Did you mean: 

Correct value of systick

ABras.1
Associate II

Hello everyone,

I write here to know if someone can help me,

how to be sure the systick value is good ? be sure that 5 seconds are well done ?

thanks to help me !

4 REPLIES 4

The clock is synchronous measure the clock with a scope, or check the timers against another time base.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Jack Peacock_2
Senior III

SysTick uses the HCLK clock, which is derived from the selected high speed oscillator (HSE, HSI, MSI). To test the oscillator frequency you need to either route the HCLK source to an external pin (see MCO in ref manual) to check with a frequency meter, or if you have a high precision LSE oscillator most STM32s have a mode for one of the timers where the timer can trigger on an LSE period. Count the number of HCLKs that occur within the LSE pulse to get the HCLK frequency.

Some HCLK frequencies will not divide evenly to get your timebase. If that's the case you need to account for roundoff error for the SysTick period. Yes, it is a cumulative error and does add up the longer you run. SysTick is not the ideal timer for scheduling over long periods of time. RTC Alarm does a much better job when you get to seconds, minutes etc. assuming you have a precision LSE source.

If you are using the HSI or MSI oscillators for HCLK then SysTick will only be accurate within the oscillator tolerance in the datasheet (i.e. not great for precise times).

Remember the SysTick stops during low power modes (STOP, STANDBY) so you have to account for lost SysTick time if you use those modes.

Jack Peacock

ABras.1
Associate II

thanks for you big answer @JackPeacock, but if i don't have a frenquency meter, there is another method (program in c for example)

@Clive1 how i can with another time base ?

GPS 1PPS into a TIMx_CHx Input Capture, using a TIM clocked with the same AHB/SYSTICK clock source.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..