Optimisation and clock speed menu - enhancements

Information on the latest releases
User avatar
RogerClark
Posts: 6917
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Optimisation and clock speed menu - enhancements

Post by RogerClark » Sun Jul 30, 2017 8:12 am

Thanks to @mtiutiu, I've added an optimisation menu to all F1 boards

(@mtiutiu did a PR for the F1, F3 and F4 but the default was not for the same optimisation that we currently use (-Os optimise for size), so I've had to change the menu items order and I've only had time to do this for the F1

On a related topic
I've also copied the CPU frequency menu to all F1 boards except the Nucleo RB (As I think the Nucleo uses its RC oscillator instead of a crystal by default)

And...

I've added a "Turbo" over clocked to 128Mhz, which is the fastest available PLL (16 x) for the 8MHz crystal that most of these boards .

Please note, the USB does not work in this mode, and you will need to manually reset to upload if you are using the Bootloader (as thats via USB)

But the speed is quite impressive.

I've been testing on the ILI9441 display running the graphic test and it really flies!

Its considerably overclocking the SPI, as it will be running at 128/2 = 64Mhz, which is well beyond the spec of the STM32 and also the ILI9341 !!

Edit. I measured the temperature of the STM32F103C8 after running at 128Mhz for half an hour and its about 6 degrees C above ambient
(Ambient was 22deg C, MCU is 28 deg C)
So no worries about overheating in a domestic environmental setting

victor_pv
Posts: 1654
Joined: Mon Apr 27, 2015 12:12 pm

Re: Optimisation and clock speed menu - enhancements

Post by victor_pv » Sun Jul 30, 2017 12:44 pm

RogerClark wrote:
Sun Jul 30, 2017 8:12 am

Please note, the USB does not work in this mode, and you will need to manually reset to upload if you are using the Bootloader (as thats via USB)
Did you add a compiler warning somewhere? if not, it may be good to do before we get a flood of messages asking why USB doesn't work.

User avatar
RogerClark
Posts: 6917
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Optimisation and clock speed menu - enhancements

Post by RogerClark » Sun Jul 30, 2017 9:27 pm

Good idea.

I will add a big warning for the 128 MHz speed setting.

zmemw16
Posts: 1420
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Optimisation and clock speed menu - enhancements

Post by zmemw16 » Sun Jul 30, 2017 10:08 pm

would it be possible to add "+USB" to those speeds in the menu at which it could be used ?
srp

User avatar
RogerClark
Posts: 6917
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Optimisation and clock speed menu - enhancements

Post by RogerClark » Sun Jul 30, 2017 11:27 pm

zmemw16 wrote:
Sun Jul 30, 2017 10:08 pm
would it be possible to add "+USB" to those speeds in the menu at which it could be used ?
srp
No. The STM32F103 does not officially support clock speeds above 72Mhz, so its impossible to configure the USB hardware to work in these cases.

In fact the STM32F013 is quite limited in the range of clock frequencies where USB will work. Those being only 48Mhz and 72Mhz.

This is because the USB clock is derived from the main system clock and there is only one bit field to select 2 possible PLL values (1 or 1.5 division from the main clock)

Re: Victor's idea.

I've checked, but warnings are not displayed unless you have verbose turned on the preferences, so I'm not sure that would help.

Perhaps I should add.

NO USB SERIAL - NEEDS MANUAL RESET

to the end of that speed setting

ropa
Posts: 7
Joined: Tue Jul 25, 2017 6:23 am

Re: Optimisation and clock speed menu - enhancements

Post by ropa » Mon Jul 31, 2017 2:45 am

Thank you very much.

User avatar
mrburnette
Posts: 1803
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: Optimisation and clock speed menu - enhancements

Post by mrburnette » Mon Jul 31, 2017 3:07 am

RogerClark wrote:
Sun Jul 30, 2017 11:27 pm
<...>
Re: Victor's idea.

I've checked, but warnings are not displayed unless you have verbose turned on the preferences, so I'm not sure that would help.
<...>
Having "verbose" On is a best practice. Forum members here should be expected to follow best practices; I did not see it just now when a did a quick review if the WiKi but I may have overlooked it.

Ray

User avatar
RogerClark
Posts: 6917
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Optimisation and clock speed menu - enhancements

Post by RogerClark » Mon Jul 31, 2017 3:11 am

BTW. I've updated the repo so there is a much bigger warning in upper case which reads

Overclocked 128Mhz NO USB SERIAL. MANUAL RESET NEEDED TO UPLOAD

Hopefully this will be enough so that anyone who picks that option will know that its overclocked and there is No USB Serial and also they need to manually reset to upload

But, I can pretty much guarantee that even this is not obvious enough and someone will complain the USB is not working when its overclocked etc etc

I'm also thinking of adding an option to run the CPU as slow as possible, which would be 8Mhz, by bypassing the PLL completely.
This gives lowest power use, for anyone who wants to run the CPU all the time on a battery.

Note. Slowest CPU speed is not necessarily the best way for low power operation, as going into Sleep mode takes less power, but of course no processing is possible in this mode and you have to wake via internal or external interrupt

But I've had a few projects where it was complicated to code the firmware to use low power and external interrupt because I needed millisecond timing while the STM32 was sleeping...
Hence 8Mhz clock speed was quite useful.

pokemon99
Posts: 22
Joined: Wed Jun 07, 2017 9:09 am

Re: Optimisation and clock speed menu - enhancements

Post by pokemon99 » Wed Oct 11, 2017 6:56 am

I tested my project on 128Mhz, it works well. The project consists of LCD1602, AM2320(or other sensor is not important) and w5500(remap SPI1). But if you select in the optimization settings for Smallest Code with LTO, the size of the sketch is noticeably reduced, but attachInterrupt does not work and strcat does not accept long values. This is what I noticed

User avatar
RogerClark
Posts: 6917
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Optimisation and clock speed menu - enhancements

Post by RogerClark » Wed Oct 11, 2017 9:44 am

pokemon99 wrote:
Wed Oct 11, 2017 6:56 am
I tested my project on 128Mhz, it works well. The project consists of LCD1602, AM2320(or other sensor is not important) and w5500(remap SPI1). But if you select in the optimization settings for Smallest Code with LTO, the size of the sketch is noticeably reduced, but attachInterrupt does not work and strcat does not accept long values. This is what I noticed
Thanks

I've noticed other issues with LTO, so I'm not sure how stable it is.

Post Reply