cancel
Showing results for 
Search instead for 
Did you mean: 

Migration between STM32F4xx devices with different clock speed

Roy Ben Hayun
Associate II

We have an application already running properly on STM32F411 which runs at 100mhz.

When running it on STM32F405 which runs at 168mhz, there are issues e.g., COM port connection to PC etc.

Seems this is the difference between 100mhz and 168mhz.

See https://stm32f4-discovery.net/2015/01/properly-set-clock-speed-stm32f4xx-devices/

0690X00000ARDBwQAP.png

Any pointers and advice on what should be tuned and how would be much appreciated.

(please note... It's the first time I'm doing such tweaks related to clock speed...)

thanks!

8 REPLIES 8
S.Ma
Principal

Tell us how you ported your code as it is today. Maybe first step would be to run on the new mcu with 100 MHz then once working, cranck up to 168 MHz.

If using USB or Ethernet may require specifics. Check the clock tree difference, RCC, peripherals getting having different generations, interrupt vector table differences.

My approach to this was to read the DEVID value from the DBGMCU registers, and set the PLL and Bus clock settings appropriately.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Roy Ben Hayun
Associate II

The application is Betaflight Flight Controller (https://github.com/betaflight/betaflight).

It runs well on F411 at 100mhz, and also on STM32F303 running at 72 MHz. So the baseline is well tested.

When trying to run it on STM32F405 running at 168mhz, I noticed the COM port connection (USB cable to PC) is not working most of the time. Was told this is probably related to clock speed.

Any additional advice on what to look?

(I'm not too familiar with it yet so will have to look into the code)

S.Ma
Principal

As it's not an STM32L4 with MSI, I guess your core frequency must be a multiple of the USB needed 48MHz, so try 144 MHz.

2 * 168 / 7 = 48 and it's possible to set that. ;)

Roy Ben Hayun
Associate II

@S.Ma​ @Piranha​ @Community member​ folks, many thanks for the support. I can clearly see I'm missing some basic knowledge for understanding all the details (not experienced with MCUs). Terms like RCC, PLL, clock tree, MSI, Bus clock, DBGMCU, etc that have been mentioned - I'm partly familiar but not enough.

Say I'd like to do some homework... which of these terms or others should I learn before trying the tweaks to be able to understand what I'm doing there :) ?

S.Ma
Principal

Open the reference manual and study the clock tree first. Tools such as CubeMX will calculate the register values to get the desired frequencies and configuration which you must define and be compatible with all your application requirements.

If you use USB, you will also need a precise reference clock (external crystal?).

Play with CubeMX and maybe this learning will be a bit more intuitive with trials and errors.

Roy Ben Hayun
Associate II

sounds good.

will start reading section 6.2 (Clocks) in en.DM00031020.pdf and then do the trial-and-error with STCubeMX and evaluate the differences.