Skip to main content
Kmax18
Senior II
May 15, 2021 1:19 AM UTC
Question

STM32F1 SysTick configuration with HAL_SYSTICK_Config()

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.

This topic has been closed for replies.

2 replies

Piranha
Principal III
May 15, 2021 12:48 PM UTC

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...

Kmax18
Kmax18Author
Senior II
May 15, 2021 10:09 PM UTC

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.