Mbed forum

How do I change default clock settings?


(Roman Matveev) #1

Hi there!
Just starting to use STM32F429I-DISC1 board within MBED OS IDE (can I call it IDE?)
When measuring calculation speed I wandered: what is the default clock settings for my firmware? Looks like it is the maximum 180 MHz as the integer multiplication needs only 40 ns to execute or so. However I’d like to check it to be sure.
But much more important for me is to be able to control the clock setting with IDE (like Project/Settings menu or so) and/or in the code like

cpu_set_clock(8000000); // or
cpu_sleep(1000); // sleep and save energy for 1000 microseconds

All the functions above are just my assumption of what it could look like.

I made some search in the web (nothing useful was found) and made the post at Stack Exchange (I was proposed to use HAL which I’m not familiar with).

Why do I think it is important? It can be required in low power applications.
Why it can be important to be settable from the IDE? If I have only weak power source I will be forsed to use extra capacitors to provide power for startup period. Making the power consumption low from the very start would be a good practice for cheaper schematic.

Thank you in advance!


(Stephen Davis) #2

Roman,
Your system clock settings are defined in system_clock.c

Look at your specific MCU’s datasheet to determine how to properly set it up. In this file you’ll see precompiler defines that determine which code gets ran, most importantly “CLOCK_SOURCE” and whichever clock source your board is using (typically “USE_PLL_MSI”). This is defined in mbed_config.h and you can modify it appropriately here. The documentation within clock_source.c is also a quick reference to the system’s clocks.

Though it is possible, I don’t recommend modifying any of the source files in the mbed library. An alternative would be to create your own local copy of the source file and include it in your project, then remove the original file from the project.

Good luck!