@@ -136,71 +136,90 @@ extern "C" {
136136/* *
137137 * @brief System Clock Configuration
138138 * The system Clock is configured as follow :
139- * System Clock source = PLL (HSI )
140- * SYSCLK(Hz) = 84000000
141- * HCLK(Hz) = 84000000
139+ * System Clock source = PLL (HSE )
140+ * SYSCLK(Hz) = 96000000
141+ * HCLK(Hz) = 96000000
142142 * AHB Prescaler = 1
143143 * APB1 Prescaler = 2
144144 * APB2 Prescaler = 1
145+ * HSE Frequency(Hz) = 8000000
145146 * HSI Frequency(Hz) = 16000000
146- * PLL_M = 16
147- * PLL_N = 336
147+ * PLL_M = 8
148+ * PLL_N = 384
148149 * PLL_P = 4
149- * PLL_Q = 7
150+ * PLL_Q = 8
150151 * VDD(V) = 3.3
151- * Main regulator output voltage = Scale2 mode
152- * Flash Latency(WS) = 2
152+ * Main regulator output voltage = Scale1 mode
153+ * Flash Latency(WS) = 3
153154 * @param None
154155 * @retval None
155156 */
156157WEAK void SystemClock_Config (void )
157158{
158- RCC_ClkInitTypeDef RCC_ClkInitStruct;
159159 RCC_OscInitTypeDef RCC_OscInitStruct;
160+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
161+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
160162
161- /* Enable Power Control clock */
163+ /* *Configure the main internal regulator output voltage
164+ */
162165 __HAL_RCC_PWR_CLK_ENABLE ();
163166
164- /* The voltage scaling allows optimizing the power consumption when the device is
165- clocked below the maximum system frequency, to update the voltage scaling value
166- regarding system frequency refer to product datasheet. */
167- __HAL_PWR_VOLTAGESCALING_CONFIG (PWR_REGULATOR_VOLTAGE_SCALE2);
167+ __HAL_PWR_VOLTAGESCALING_CONFIG (PWR_REGULATOR_VOLTAGE_SCALE1);
168168
169- /* Enable HSI Oscillator and activate PLL with HSI as source */
170- RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
171- RCC_OscInitStruct.HSIState = RCC_HSI_ON;
172- RCC_OscInitStruct.HSICalibrationValue = 0x10 ;
169+ /* *Initializes the CPU, AHB and APB busses clocks
170+ */
171+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
172+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
173+ RCC_OscInitStruct.LSIState = RCC_LSI_ON;
173174 RCC_OscInitStruct.PLL .PLLState = RCC_PLL_ON;
174- RCC_OscInitStruct.PLL .PLLSource = RCC_PLLSOURCE_HSI ;
175- RCC_OscInitStruct.PLL .PLLM = 16 ;
176- RCC_OscInitStruct.PLL .PLLN = 336 ;
175+ RCC_OscInitStruct.PLL .PLLSource = RCC_PLLSOURCE_HSE ;
176+ RCC_OscInitStruct.PLL .PLLM = 8 ;
177+ RCC_OscInitStruct.PLL .PLLN = 384 ;
177178 RCC_OscInitStruct.PLL .PLLP = RCC_PLLP_DIV4;
178- RCC_OscInitStruct.PLL .PLLQ = 7 ;
179- if (HAL_RCC_OscConfig (&RCC_OscInitStruct) != HAL_OK)
179+ RCC_OscInitStruct.PLL .PLLQ = 8 ;
180+ if (HAL_RCC_OscConfig (&RCC_OscInitStruct) != HAL_OK)
180181 {
181182 /* Initialization Error */
182183 while (1 );
183184 }
184- /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
185- clocks dividers */
186- RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
185+
186+ /* *Initializes the CPU, AHB and APB busses clocks
187+ */
188+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
189+ |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
187190 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
188191 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
189192 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
190193 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
191- if (HAL_RCC_ClockConfig (&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
194+
195+ if (HAL_RCC_ClockConfig (&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK)
192196 {
193197 /* Initialization Error */
194198 while (1 );
195199 }
200+
201+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S|RCC_PERIPHCLK_RTC;
202+ PeriphClkInitStruct.PLLI2S .PLLI2SN = 192 ;
203+ PeriphClkInitStruct.PLLI2S .PLLI2SM = 8 ;
204+ PeriphClkInitStruct.PLLI2S .PLLI2SR = 2 ;
205+ PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
206+ if (HAL_RCCEx_PeriphCLKConfig (&PeriphClkInitStruct) != HAL_OK)
207+ {
208+ /* Initialization Error */
209+ while (1 );
210+ }
211+
212+ /* *Configure the Systick interrupt time
213+ */
196214 HAL_SYSTICK_Config (HAL_RCC_GetHCLKFreq ()/1000 );
197215
216+ /* *Configure the Systick
217+ */
198218 HAL_SYSTICK_CLKSourceConfig (SYSTICK_CLKSOURCE_HCLK);
199219
200220 /* SysTick_IRQn interrupt configuration */
201221 HAL_NVIC_SetPriority (SysTick_IRQn, 0 , 0 );
202222}
203-
204223#ifdef __cplusplus
205224}
206225#endif
0 commit comments