STM32cubeMX版本:6.11.0
现象
STM32cubeMX配置Systick的时钟,不管选择不分频 还是8分频。
生成的代码都是一样的,代码都是不分频。
即不管选择不分频还是8分频,Systick都是使用的系统时钟
函数调用
HAL_Init() →
HAL_InitTick(TICK_INT_PRIORITY) →
HAL_SYSTICK_Config(SystemCoreClock / (1000UL / (uint32_t)uwTickFreq)) →
SysTick_Config(TicksNumb)
各个函数的源码如下所示:
__weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
{
/* Check uwTickFreq for MisraC 2012 (even if uwTickFreq is a enum type that don't take the value zero)*/
if((uint32_t)uwTickFreq == 0UL)
{
return HAL_ERROR;
}
/* Configure the SysTick to have interrupt in 1ms time basis*/
if (HAL_SYSTICK_Config(SystemCoreClock / (1000UL / (uint32_t)uwTickFreq)) > 0U)
{
return HAL_ERROR;
}
/* Configure the SysTick IRQ priority */