@@ -122,14 +122,16 @@ WEAK void SystemClock_Config(void)
122122
123123 RCC_OscInitTypeDef RCC_OscInitStruct;
124124 RCC_ClkInitTypeDef RCC_ClkInitStruct;
125+ RCC_PeriphCLKInitTypeDef PeriphClkInit;
125126
126127 /* Configure the main internal regulator output voltage */
127128 __HAL_PWR_VOLTAGESCALING_CONFIG (PWR_REGULATOR_VOLTAGE_SCALE1);
128129
129130 /* Initializes the CPU, AHB and APB busses clocks */
130- RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
131+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48 ;
131132 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
132- RCC_OscInitStruct.HSICalibrationValue = 16 ;
133+ RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
134+ RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
133135 RCC_OscInitStruct.PLL .PLLState = RCC_PLL_ON;
134136 RCC_OscInitStruct.PLL .PLLSource = RCC_PLLSOURCE_HSI;
135137 RCC_OscInitStruct.PLL .PLLMUL = RCC_PLLMUL_4;
@@ -149,6 +151,12 @@ WEAK void SystemClock_Config(void)
149151 if (HAL_RCC_ClockConfig (&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) {
150152 _Error_Handler (__FILE__, __LINE__);
151153 }
154+
155+ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
156+ PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
157+ if (HAL_RCCEx_PeriphCLKConfig (&PeriphClkInit) != HAL_OK) {
158+ _Error_Handler (__FILE__, __LINE__);
159+ }
152160}
153161
154162#ifdef __cplusplus
0 commit comments