@@ -192,12 +192,48 @@ extern "C" {
192
192
*/
193
193
WEAK void SystemClock_Config (void )
194
194
{
195
- // Here copy the desired System Clock Configuration
196
- // It could be generated thanks STM32CubeMX after code generation for Toolchain/IDE: 'SW4STM32',
197
- // available in main.c)
198
- // or
199
- // copied from a STM32CubeYY project examples
200
- // where 'YY' could be F0, F1, F2, F3, F4, F7, L0, L1, L4)
195
+ RCC_OscInitTypeDef RCC_OscInitStruct;
196
+ RCC_ClkInitTypeDef RCC_ClkInitStruct;
197
+
198
+ /* *Initializes the CPU, AHB and APB busses clocks
199
+ */
200
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
201
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
202
+ RCC_OscInitStruct.PLL .PLLState = RCC_PLL_ON;
203
+ RCC_OscInitStruct.PLL .PLLSource = RCC_PLLSOURCE_HSE;
204
+ RCC_OscInitStruct.PLL .PLLM = 8 ;
205
+ RCC_OscInitStruct.PLL .PLLN = 240 ;
206
+ RCC_OscInitStruct.PLL .PLLP = RCC_PLLP_DIV2;
207
+ RCC_OscInitStruct.PLL .PLLQ = 5 ;
208
+ if (HAL_RCC_OscConfig (&RCC_OscInitStruct) != HAL_OK)
209
+ {
210
+ while (1 );
211
+ }
212
+
213
+ /* *Initializes the CPU, AHB and APB busses clocks
214
+ */
215
+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
216
+ |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
217
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
218
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
219
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
220
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
221
+
222
+ if (HAL_RCC_ClockConfig (&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK)
223
+ {
224
+ while (1 );
225
+ }
226
+
227
+ /* *Configure the Systick interrupt time
228
+ */
229
+ HAL_SYSTICK_Config (HAL_RCC_GetHCLKFreq ()/1000 );
230
+
231
+ /* *Configure the Systick
232
+ */
233
+ HAL_SYSTICK_CLKSourceConfig (SYSTICK_CLKSOURCE_HCLK);
234
+
235
+ /* SysTick_IRQn interrupt configuration */
236
+ HAL_NVIC_SetPriority (SysTick_IRQn, 0 , 0 );
201
237
}
202
238
203
239
#ifdef __cplusplus
0 commit comments