cancel
Showing results for 
Search instead for 
Did you mean: 

Systick sync with TIM3

Carl_G
Senior II

I configured STM32CubeMX to have a timebase source as SysTick. I'm using this for my scheduler. its running at 1ms. I also configured tim3 for 1ms sortof.

Carl_G_0-1750822395221.png

But for some reason this will not stay in synch with systick. They are drifting constantly apart.

Carl_G_1-1750822499426.png

The green lines are racing across my screen. Even though they are 1ms period as well. But obviously they couldn't be. I just don't understand why. Or maybe I have an issue with my data??

4 REPLIES 4
Carl_G
Senior II

I should add that if I set the ARR to 500 then they stay in synch.

waclawek.jan
Super User

Well, then SysTick divider is set incorrectly.

 

JW

Saket_Om
ST Employee

Hello @Carl_G 

Please specify the STM32 series you are working on. 

If the clock sources for SysTick and TIM3 are not derived from the same base clock or are configured differently, they may not stay synchronized

Note that there is a driver that can be used generate systick from timer (stm32xxxx_hal_timebase_tim_template.c)). To do this you need to choose TIMx as timebase in CubeMX. 

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om
Carl_G
Senior II

Stm32G071. I checked systick in software and the debugger and it's 15999. I want to believe it's an illusion on my oscilloscope but the fact that setting the period to 500 works is confusing.