Skip to main content
Graduate II
May 15, 2021
Question

STM32F1 SysTick configuration with HAL_SYSTICK_Config()

  • May 15, 2021
  • 1 reply
  • 4944 views

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.

    1 reply

    Graduate II
    May 15, 2021

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

    Kmax18Author
    Graduate II
    May 15, 2021

    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.