I find the STM32 clock stuff pretty wierd. I have the 16MHz crystal (HSE) on a custom board and the HSI clock is also 16MHz in my SystemClock_Config() I want to switch betrween the two and expect both versions to work interchangably if I only change the source for the DLL as below:
#if 0
// Use HSI
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI ;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
#else
// Use HSE
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
#endif
If do this however, HSI is fine but with HSE, Serial1 fails (the rest of the trivial code works ok). CubeMX supports my expectation that both variants should work. What do I oversee here? BTW: I believe the B-G431B-ESC1 works by default on the HSI clock as well, ignoring the external crystal.