Skip to main content
GRizz.1
Visitor II
January 21, 2021
Question

I am using STM32CubeMX to generate an MDK-ARM project for NUCLEO-L552ZE-Q. If, in the clock configuration tab, I select HCLK/8 as SysTick clock source, the SysTick initialization code generated produces a wrong time base.

  • January 21, 2021
  • 0 replies
  • 447 views

The problem arises because by selecting both HCLK and HCLK/8 the SysTick is always initialized like this:

SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk;

thus selecting HCLK as clock source in both cases.

Maybe the correct code should be:

SysTick->CTRL = SysTick_CTRL_ENABLE_Msk;

if HCLK/8 is to be taken as clock source.

This topic has been closed for replies.