cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F1 SysTick configuration with HAL_SYSTICK_Config()

Kmax18
Senior II

I am using the STM32F1 HAL and low-layer driver library. The 1ms SysTick timer works well. One of ST's examples computes the system clock ticks between SysTick interrupts: with SystemCoreClock=16,000,000 Hz, and uwTickFreq=1 kHz this function outputs 16,000 ticks:

 HAL_SYSTICK_Config(SystemCoreClock / (1000U / uwTickFreq))

However, why is the denominator a division and not (1000U * uwTickFreq)? This product would result in a division of two frequencies, which cancels the units and provides a unitless number of system clock ticks. For a Time Base of 1ms it is irrelevant, but for another time base it should matter.

2 REPLIES 2
Piranha
Chief II

In reality the uwTickFreq is not a frequency but a complete opposite - period in milliseconds. Don't use code written by dummies and you will have less problems...

Hi Piranha, thank you for the quick response. Much appreciated. I am fairly new to the STM32 series and have not yet evaluated available libraries. So I decided to use ST's HAL library, because it is well documented and supported. Over time I expect to write my own libraries. The ST Community is very helpful. Thanks again.