@@ -136,71 +136,90 @@ extern "C" {
136
136
/* *
137
137
* @brief System Clock Configuration
138
138
* 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
142
142
* AHB Prescaler = 1
143
143
* APB1 Prescaler = 2
144
144
* APB2 Prescaler = 1
145
+ * HSE Frequency(Hz) = 8000000
145
146
* HSI Frequency(Hz) = 16000000
146
- * PLL_M = 16
147
- * PLL_N = 336
147
+ * PLL_M = 8
148
+ * PLL_N = 384
148
149
* PLL_P = 4
149
- * PLL_Q = 7
150
+ * PLL_Q = 8
150
151
* 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
153
154
* @param None
154
155
* @retval None
155
156
*/
156
157
WEAK void SystemClock_Config (void )
157
158
{
158
- RCC_ClkInitTypeDef RCC_ClkInitStruct;
159
159
RCC_OscInitTypeDef RCC_OscInitStruct;
160
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
161
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
160
162
161
- /* Enable Power Control clock */
163
+ /* *Configure the main internal regulator output voltage
164
+ */
162
165
__HAL_RCC_PWR_CLK_ENABLE ();
163
166
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);
168
168
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;
173
174
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 ;
177
178
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)
180
181
{
181
182
/* Initialization Error */
182
183
while (1 );
183
184
}
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;
187
190
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
188
191
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
189
192
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
190
193
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)
192
196
{
193
197
/* Initialization Error */
194
198
while (1 );
195
199
}
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
+ */
196
214
HAL_SYSTICK_Config (HAL_RCC_GetHCLKFreq ()/1000 );
197
215
216
+ /* *Configure the Systick
217
+ */
198
218
HAL_SYSTICK_CLKSourceConfig (SYSTICK_CLKSOURCE_HCLK);
199
219
200
220
/* SysTick_IRQn interrupt configuration */
201
221
HAL_NVIC_SetPriority (SysTick_IRQn, 0 , 0 );
202
222
}
203
-
204
223
#ifdef __cplusplus
205
224
}
206
225
#endif
0 commit comments