An external crystal oscillator is running without an error while 'SystemCoreClock' is wrong
Hello,
I have designed my PCB with STM32F103CBT6 and a 16MHz crystal oscillator. When I generate code with CubeMX with the clock configuration like the one of the attached images, 'SystemCoreClock', a global variable shows it's 36MHz while it should be 72MHz.
Also, the led blink interval should wait 1000ms while it does only 500ms. It seems the clock is not running properly.
As you can see in the last image, I set breakpoints at Error_Handler(), but I couldn't catch any error there so I assume the config was okay.
Here is what I did:
- generate the code with the settings shown in the images
- copy all files under 'Core' folder and paste on PlatformIO project src folder
- add the following two lines in the while loop
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
HAL_Delay(1000);
I use PlatformIO to build/upload/debug on ubuntu 24.04.
I would appreciate if someone could guide me how to debug this. I'm a noob at electronics but I have a logic analyzer, 4ch 100MHz oscilloscope, and lab power supply.
MCU: STM32F103CBT6
Crystal Oscillator: X322516MLB4SI
Load capacitor: 10pF





