Hello,
I am using STM32L4A6VGTxP with CubeIDE and want to create a system with FreeRTOS.
However, I am having the following problem when running the system under FreeRTOS while changing the SystemClock.
Is there a solution?
Configuration
・Custom boards using the STM32L4A6VGTxP microcontroller
・Using STM32CubeIDE v1.9.0
・Firmware Package STM32Cude FW_L4 V1.17.2
・FreeRTOS v10.3.1 with CMSIS v2
Problem Description
FreeRTOS is initialized with the system clock set at HSI 16MHz at microcontroller startup.
If the system clock is subsequently changed, the OS time remains set at 16MHz.
How can I synchronize the OS time when the system clock is changed?
For example
(1) If you change the system clock from HSI 16MHz to HSI 80MHz
→osDelay(1000), the Delay time will be 200ms.
Execute osEventFlagsWait(ef_id, flags, options, 1000), the timeout time will be 200ms.
When HAL_Delay(1000) is executed, Delay time becomes 1000ms.
(2) When changing from HSI 16MHz to MSI 4MHz
→When osDelay(1000) is executed, Delay time becomes 4000ms.
When osEventFlagsWait(ef_id, flags, options, 1000) is executed, timeout time becomes 4000ms.
Execute HAL_Delay(1000), Delay time will be 1000ms.
When SystemClock is changed from 16MHz to 80MHz,
If we use Systick for Timebase Source,
Delay time for HAL_Delay(1000) and osDelay(1000) is the same at 1000ms.
However, when TIM6 is used for Timebase Source,
Delay time for HAL_Delay(1000) is 1000ms, but Delay time for osDelay(1000) is 200ms.
When using RTOS with STM32CubeIDE, it is strongly recommended to use a HAL timebase source other than Systick.
I do not understand why there is a difference in delay time between HAL_Delay and osDelay when Timebase is set to TIM6.
I would also like to know what kind of reconfiguration would maintain 1Tick=1ms.
Thank you in advance for your help.