Options for a lot of cpu clock frequencies.

What could be included in further releases
razvitm
Posts: 38
Joined: Sat Apr 11, 2020 12:35 pm

Options for a lot of cpu clock frequencies.

Post by razvitm »

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.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Options for a lot of cpu clock frequencies.

Post by fpiSTM »

STM32 has no such option. I guess you talk about Roger's core (libmaple)
stas2z
Posts: 131
Joined: Mon Feb 24, 2020 8:17 pm
Answers: 8

Re: Options for a lot of cpu clock frequencies.

Post by stas2z »

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

Image
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: Options for a lot of cpu clock frequencies.

Post by mrburnette »

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.
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.

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
razvitm
Posts: 38
Joined: Sat Apr 11, 2020 12:35 pm

Re: Options for a lot of cpu clock frequencies.

Post by razvitm »

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

Image
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?
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Options for a lot of cpu clock frequencies.

Post by fpiSTM »

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) {
...
 }
stas2z
Posts: 131
Joined: Mon Feb 24, 2020 8:17 pm
Answers: 8

Re: Options for a lot of cpu clock frequencies.

Post by stas2z »

it will be in the main.c, just copy paste this function to your sketch and add extern "C" like fpiSTM said
razvitm
Posts: 38
Joined: Sat Apr 11, 2020 12:35 pm

Re: Options for a lot of cpu clock frequencies.

Post by razvitm »

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?
razvitm
Posts: 38
Joined: Sat Apr 11, 2020 12:35 pm

Re: Options for a lot of cpu clock frequencies.

Post by razvitm »

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...
Last edited by razvitm on Mon May 04, 2020 9:49 am, edited 1 time in total.
stas2z
Posts: 131
Joined: Mon Feb 24, 2020 8:17 pm
Answers: 8

Re: Options for a lot of cpu clock frequencies.

Post by stas2z »

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...
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.

Example:
Image
Post Reply

Return to “Ideas & suggestions”