2025-01-15 09:50 AM - last edited on 2025-01-15 09:55 AM by Andrew Neil
Dear all,
I just came across something strange.
I debugged into the function HAL_InitTick() to better understand how the OS tick (SysTick) is managed if FreeRTOS is used. I'm using TIM16 for the SysTick of the OS. At the beginning of HAL_InitTick() the function HAL_RCC_GetPCLK2Freq() is called. The return value is used to set the systick timer (in my case TIM16 on a STM32L432 device).
My clock configuration for my device is set for PCLK2 = 80MHz. However, the function HAL_RCC_GetPCLK2Freq() returns 40.000.000. So half of the actual frequency. In the following the prescaler is set to 3 and the period to 999. So for my understanding the timer period until it will reset to 0 and raise an interrupt will be ((40.000.000/3)*1000) *(1/40.000.000). So this gives me a totally wrong value that certainly is not the case (I'm actually sure for other reasons that my device runs at 80MHz instead of 40MHz). Here is how it looks like just before entering HAL_TIM_Base_Init().
Any idea bout my misunderstanding?
Best Regards
Markus