2015-08-25 11:16 PM
Hi
Please refer below code to change clock source from external HSE to internal HSI /* Enable HSE Oscillator and activate PLL with HSE as source */#if 0 // Choose External Crystal (HSE) As Source RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = 25; RCC_OscInitStruct.PLL.PLLN = 240; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = 5; HAL_RCC_OscConfig(&RCC_OscInitStruct);#else // Choose Internal Crystal - 16MHz (HSI) As Source RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSEState = RCC_HSE_OFF; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; RCC_OscInitStruct.PLL.PLLM = 16; RCC_OscInitStruct.PLL.PLLN = 240; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = 5; HAL_RCC_OscConfig(&RCC_OscInitStruct);#endif /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3);We observed that the most of the peripherals are working fine with this change from HSE to HSIhowever the USB host communication (PB14 PB15) which is connected to external HUB IC(which uses 48Mhz crystal) to communicate with 4 USB devices is not as same as we observed with HSE configuration.Are we missing anything in changing from HSE to HSI, do we need to change anything somewhere else for USB host communication to work normalAssist us on this2015-08-26 02:04 AM
Hi vandal.sangamesh,
If I guess that you use one STM32F4xx product so according to any STM32F4 datasheet, The USB OTG full-speed controller requires a dedicated 48 MHz clock that is generated by a PLL connected to the HSE oscillator, then it means that it's unable to use HSI.
For more information please refer to sections related to USB in your STM32 reference manual and datasheet.-Syrine-2015-08-26 02:54 AM
Can we not generate the 48 MHz clock from PLL clocked by HSI oscillator (which we are already doing)?
2015-08-26 03:30 AM
According to the reference manual:
“A main PLL (PLL) clocked by the HSE or HSI oscillator and featuring two different output clocks:– The first output is used to generate the high speed system clock (up to 180 MHz)– The second output is used to generate the clock for the USB OTG FS (48 MHz), the random analog generator (≤48 MHz) and the SDIO (≤48 MHz).�?In the case of USB OTG FS, the specification requires the use of HSE.-Syrine-2015-08-26 03:47 AM
The USB clock must be accurate. HSI is not good enough so the external crystal oscillator must be used.
2017-04-27 11:24 PM
Hi ,
Is it possible to use HSI for DCMI and LTDC ?