Preface
This situation is easy to appear in our debugging process, the most likely reason is that you have not selected the correct RCC clock source in the STMCube.
It is difficult to find the reason by looking up the code
After repeated searches, it was found that the clock source selection in STM32CubeMX was wrong.
This is the place below, remember to select the same clock source as the clock tree configuration