PlatformIO Community

Changing clock settings in Arduino for STM32


In Maple core, clock settings can be changed as simply as adding build flags to platformio.ini file. E.g. -DUSE_HSI_CLOCK or -DBOARD_RCC_PLLMUL=RCC_PLLMUL_6.

Is there a similar feature in the official STM Arduino Core?

The function that implements setting up the clock is always marked as weak in the variant, so that user / firmware code can overwrite it.

So in the src/main.cpp one can do

extern "C" void SystemClock_Config(void)
  // clock init code here... 

With the function’s content either being auto-generated by STM32CubeMX or copied and adapted from an existing variant.

This was also previously discussed in e.g. STM32F407VET6 external oscillator configuration

But the second link (to stm32f407vet6 external oscillator configuration) is broken.

URL was fixed

[blah blah min 20 chars…]

1 Like