cancel
Showing results for 
Search instead for 
Did you mean: 

SysTick vs Timer Interrupt

jonfs2000
Associate II
Posted on February 06, 2014 at 12:08

Hi,

I like to have a millisecond interrupt. I normally use one of the timer to create millisecond interrupt.

But is there any advantage of using SysTick for millisecond interrupt?

What is SysTick?

Thank you

John

#stm32-systick #systick
7 REPLIES 7
chen
Associate II
Posted on February 06, 2014 at 13:27

Hi

''What is SysTick?''

SysTick is the timer that is built into the ARM Cortex M3/4 core.

It is normally used to provide OS/RTOS clock for context switching or timing services.

''But is there any advantage of using SysTick for millisecond interrupt?''

Not sure. It may have advantages over peripheral timers in that it should be able to put the core into 'privilage' modes where as the peripheral timers probably cannot.

j-fischer-gundlach
Associate II
Posted on February 06, 2014 at 14:48

Since it is bulid into the ARM architecture, it would make u independent from the derivate you´re using. It would be portable to every uC wich is based on ARM. This could be an advantage. So i guess, if i´d we writing something wich is supposed to work based on CMSIS and serve as an general starting point, i´d make use of the sys_tick, if no OS is supposed to be used.

Posted on February 06, 2014 at 17:20

It's also significantly less complex than a 1-4 channel TIM, so is likely to consume less power.

I'd use SysTick for a 1 ms timer.

There are also buried TIM units in some of the STM32 which aren't connected to the outside world. I'd burn these first before using externally facing ones. Ultimately it depends on how many resources your project needs, as each timer has only one counting element.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
carl2399
Associate II
Posted on February 06, 2014 at 23:11

I posted a message on the forum several years ago. I have a 2ppm oscillator driving the STM32F2xx, and but I seemed to be get unusual drifting in timing. In the end what I found was that a 1ms SysTick is not the same as a 1ms Timer interrupt. The SysTick seemed to drift around a bit with a ''mind of it's own''. I never got to the bottom of it, but I suspect that SysTick might be derived (always) from the internal oscillator.

SysTick is easy to though. If you're happy to call them ''System Ticks'' - that's fine. If you're happy for them to occur every 1ms with about 99% accuracy - that's fine. If you need an accurate time (milli-seconds) reference then use a Timer!

At least go through the exercise of comparing the two if accuracy is important.

Posted on February 06, 2014 at 23:24

In some Cortex-Mx designs the SysTick can be clocked from a different source, here it's clocked from the same source as the processor and the peripherals, or 1/8 of it. Chances are it will not be clocked directly by the accurate HSE, but rather whatever the VCO/PLL is generating.

Not disclaiming your experience, but I'd expect SysTick to be synchronous with the timer clocks.

Any DMA or Low-Power modes used with the system you observed this on?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
carl2399
Associate II
Posted on February 07, 2014 at 06:53

Hi Clive, 

The datasheet is as you say, but my experience and doing delta's between SysTick and TIMx said otherwise. 

I'm not using any sleep modes (including WFI, WFE etc). I am using DMA's, so if there's something else I should know, then I'm certainly curious.

When I compared TIMx (1kHz) to TIMy (6Khz) they were completely lock-step with each other over a 24 hour period.