While working on some power saving routines I ran into a problem with FreeRTOS. The OS assumes the clock stays at a fixed frequency, set by configCPU_CLOCK_HZ. For the STM32 the system tick timer uses this value to calculate the timer reload. However the STM32 can vary the instruction clock (SYSCLK) anywhere from 4MHZ to 72MHZ with substantial power savings at lower frequencies, significant when running on batteries or off the USB Vbus power.
I’d like to suggest changing configCPU_CLOCK_HZ into a RAM location instead of a compile time option. And for the STM32 it would be nice if the SysTick timer load routine in port.c was exposed so that the clock frequency changes would affect the SysTick timer in one routine, instead of replacing the one in port.c.
The other question is where best to vary the frequency? My inclination is to post a change request, and then switch the CPU clock during the tick hook routine, so that (on the STM32) the Systick timer can be modified to keep to the expected tick rate with a minimal loss from resetting the timer.