cancel
Showing results for 
Search instead for 
Did you mean: 

The correct way to scale main clock frequency when using Azure RTOS ThreadX

Waelha
Associate II

For a specific application, I’d like to decrease the main clock (MSI in this case) in runtime. Frequency scaling itself is not an issue but after scaling, Threadx timings are not correct anymore (since TX_TIMER_TICKS_PER_SECOND is not correct anymore) even after calling HAL_InitTick again and reconfiguring the timebase timer (TIM7 in my case).

I’ve noticed that the system clock is hardcoded in the assembly file tx_initialize_low_level.s as

SYSTEM_CLOCK     =  4000000

generated directly from CubeMX.

What would be the correct way to refresh Threadx timings after the main frequency change?

The frequency change in my case will occur in an interrupt context and I don’t care about the state of the threads a.k.a. Threadx can be reinitialized if needed.

for reference, STM32L476x, CubeIDE 1.10.1. CubeMX 6.6.1 are used. Trying to switch between 4MHz and 400KHz.

0 REPLIES 0