Options for a lot of cpu clock frequencies.
Options for a lot of cpu clock frequencies.
The Megacore allows for a wide variety of clocks for running the atmega2560 on external crystal oscillators, I would like the stm32duino to give more than the current 3 options for core frequency. So 72MHz, 48MHz and 128MHz could be complemented with 16MHz, 8MHz and if possible, lower clocks too.
Re: Options for a lot of cpu clock frequencies.
STM32 has no such option. I guess you talk about Roger's core (libmaple)
Re: Options for a lot of cpu clock frequencies.
roger's core allows these frequencies cuz its compatible with usb clocking
with this (stm32 official) core (not roger's one) you can configure your mcu any way you wish by overriding weak SystemClock_Config with cumbemx generated where you can play with clock parameters

with this (stm32 official) core (not roger's one) you can configure your mcu any way you wish by overriding weak SystemClock_Config with cumbemx generated where you can play with clock parameters

-
- Posts: 633
- Joined: Thu Dec 19, 2019 1:23 am
Re: Options for a lot of cpu clock frequencies.
Even with Megacore, you run great risks of libraries not working. I am intimately familiar with Roger's core and it's death came before the webpage crashed. The increasing complexity created by added options created a testing nightmare with simply too many permutations to humanly verify. Features created failures that then required fixing.razvitm wrote: Sat Apr 11, 2020 3:01 pm The Megacore allows for a wide variety of clocks for running the atmega2560 on external crystal oscillators, I would like the stm32duino to give more than the current 3 options for core frequency. So 72MHz, 48MHz and 128MHz could be complemented with 16MHz, 8MHz and if possible, lower clocks too.
If you need the capabilities you request, you need to skip Arduino'ish cores and move to a full development environment, not one that creates a limiting wrapper around the very flexible tools.
Ray
Re: Options for a lot of cpu clock frequencies.
I'll try that first thing when I get home. So I select the MCU in CubeMx, select all the pheripherals I'll be using, and set the clocks, export a file, and use that file to overwrite some file in the STM32duino ST core?stas2z wrote: Sat Apr 11, 2020 6:25 pm roger's core allows these frequencies cuz its compatible with usb clocking
with this (stm32 official) core (not roger's one) you can configure your mcu any way you wish by overriding weak SystemClock_Config with cumbemx generated where you can play with clock parameters
![]()
Re: Options for a lot of cpu clock frequencies.
For the STM32 core, simply define your new SystemClock_Config at sketch level with extern "C"
Code: Select all
extern "C" void SystemClock_Config(void) {
...
}
Re: Options for a lot of cpu clock frequencies.
it will be in the main.c, just copy paste this function to your sketch and add extern "C" like fpiSTM said
Re: Options for a lot of cpu clock frequencies.
Please help me with step by step instructions of using cubemx, arduino and the official ST core to run the stm32f103rc at say 1MHz, for the blinky sketch. I have cubemx, arduino and the st core installed. What do I do with the files generated by cubemx? Do I copy them in the arduino blinky sketch folder?
Re: Options for a lot of cpu clock frequencies.
So I managed to run the MCU at 4MHz by looking into the cubemx generated files and copy-pasting the prescaler values in the stm32duino file:
c:\Users\Razvan\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\variants\PILL_F103XX\variant.cpp
I did this beause I couldn't figure out how to include the cubemx generated files in my sketch, it might be simple but someone has to show me how it's done... Until I learn, I will use this workaround...
c:\Users\Razvan\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.8.0\variants\PILL_F103XX\variant.cpp
I did this beause I couldn't figure out how to include the cubemx generated files in my sketch, it might be simple but someone has to show me how it's done... Until I learn, I will use this workaround...
Last edited by razvitm on Mon May 04, 2020 9:49 am, edited 1 time in total.
Re: Options for a lot of cpu clock frequencies.
As i already said before, you only need to copy void SystemClock_Config(){...} from main.c generated by cubemx and paste it DIRECTLY into your .ino file and add extern "C" right before void SystemClock_Config(){ to say your compiler that it's a symbol with C linkage.razvitm wrote: Mon May 04, 2020 9:21 am So I managed to run the MCU at 4MHz by looking into the cubemx generated files and copy-pasting the prescaler values in the stm32duino file:
c:\Users\Razvan\AppData\Local\Arduino15\packages\STM32\hardware\stm32\1.6.1\variants\PILL_F103XX\variant.cpp
I did this beause I couldn't figure out how to include the cubemx generated files in my sketch, it might be simple but someone has to show me how it's done... Until I learn, I will use this workaround...
Example:
