Why does CubeMX "turn on" HSI if it's not referenced?
This is a bit nit-picky, but it's confusing. For a USB experiment on an STM32F103, I'm seeing an odd clock setting that isn't used and wondering why it is this way. The USB application uses an 8MHz HSE crystal as per usual.
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
:
etcWhy is the below line included at all? In stepping through the code, I don't see it being relevant:
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
Following the flow, since the clock type is HSE, then the above element is never used.
if (((RCC_OscInitStruct->OscillatorType) & RCC_OSCILLATORTYPE_HSE) == RCC_OSCILLATORTYPE_HSE)
{
// is executed.
}if (((RCC_OscInitStruct->OscillatorType) & RCC_OSCILLATORTYPE_HSI) == RCC_OSCILLATORTYPE_HSI)
{
// not executed and this is the only place RCC_HSI_ON is evaluated
}(I think this is a curious implementation of osc types via bit positions, but that's beside the point)
