sfyip / STM32F103_MSD_BOOTLOADER

STM32F103 Mass Storage Device Bootloader
MIT License
69 stars 45 forks source link

Enhancement: Change system clock to a setting commonly used for STM32F10x #11

Closed tusker-tools closed 1 year ago

tusker-tools commented 2 years ago

Today after many hours of debugging, I discovered that the clock setting of my main application was wrong, although it should obviously get correctly configured by HAL function. Without bootloader the application worked fine.

The reason is that the bootloader uses a different clock setting than my main application. But once the clock is set (e.g. by bootloader), a special procedure is required for changing the clock according to the main application's needs. The auto-generated SystemClock_Config() function does not follow the special procedure and thus is not able to set the clock correctly.

My proposal: In order to cause as little problems as possible for the main application, I propose to use the most commonly used clock setting for STM32F1. This means using external 8MHz oscillator with RCC->CFGR->PLLMUL=9 and RCC->CFGR->PLLSRC=1, which results in 72MHz system clock

tusker-tools commented 1 year ago

Integrated with PR #12 . Thank you!