At the moment I’m optimizing a device consumption (STM32 cortex M7). I already have Standby mode implemented for when the device is idle.
Now I’m also optimizing consumption during “wake up” mode. I’ve identified that most of the time we can be in “low performance” and for that I’ve configured the CPU clock at 120MHz. At some point, we need to run some algorithm that needs full power and for that I go to 480MHz.
I managed to do this switch, by setting first HSI as sysclk, changing PLL values, update peripherals, etc.
However, I’ve seen that FreeRTOS timers get messed up. I understand that this is due to ticks going faster than the expected 1ms during this “high-performance” moments.
It seems I managed to solve this by calling vPortSetupTimerInterrupt() (port.c) every time I update the system clock (this way getting SYSTICK_LOAD_REG updated). However, for this, I had to move the function declaration to portable.h (to have access to it from my code).
Is this the right approach? or should I avoid making changes in port.c, portable.h, etc.? as it has a weak definition, I was going to define a new vPortSetupTimerInterrupt but then I realize I needed access to variables such as “ulTimerCountsForOneTick”…
For the future, I will add a TODO to run the system tick with another source, so to be able to change PLL/CPU clocks freely without this impact on FreeRTOS timings. But at the moment I need to solve it somehow simpler as I don’t have time for a proper full implementation.