-
|
I attempted to override SystemClock_Config() to use HSE (8 MHz provided by the ST-Link) instead of HSI. So I copied the existing code, modified a few bits and failed. Then I rewrote the whole function using direct register access, but that failed as well. Then I tried another minimal code which directly uses HSE without PLL, that failed as well. Problem: In all three cases, the CPU and also the systick timer ran at half speed instead of the configured one. I verified the external clock signal (coming from the ST-Link) with an oscilloscope. It looks stable and has really 8 MHz. After hours of investigation I found a solution: set the HSEBYP bit. But I did not find any explanation in the reference manual. It only mentions that this bit disables the output of the HSE oscillator, so the pin can be used as a regular I/O. But that was not my problem. My problem was half speed. I did never have this issue with other STM32 models (STM32F103C8, STM32F103RB, STM32F303CC, STM32F303RE, STM32G432CB). I tried the same codes without framework in the Cube IDE, and got the same issue. So I am aware that the question is a bit off-topic, but I hope that someone can help me anyway to understand the issue. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
For a Nucleo board where the 8 MHz clock is coming from the ST-LINK MCO into OSC_IN, So the clock setup should use: RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;and Also check the Nucleo solder bridge/user manual state for the ST-LINK MCO path, but if you have already measured a stable 8 MHz on OSC_IN, bypass mode is the right fix. |
Beta Was this translation helpful? Give feedback.


For a Nucleo board where the 8 MHz clock is coming from the ST-LINK MCO into OSC_IN,
RCC_HSE_BYPASSis the correct configuration. That signal is an external clock source, not a crystal/resonator connected across OSC_IN/OSC_OUT.So the clock setup should use:
and
HSE_VALUEshould match the actual 8 MHz input. Running it as normalRCC_HSE_ONmakes the MCU try to drive/use the HSE oscillator circuit as if a crystal were attached, so the half-speed behavior is a symptom of an invalid clock-source mode rather than a valid alternate setting.Also check the Nucleo solder bridge/user manual sta…