Skip to content

Commit a4b67a6

Browse files
committed
- Added clock configuration from STM32CubeMX (was default clock previously)
1 parent 2969bc2 commit a4b67a6

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

‎variants/STM32F3xx/F303V(D-E)(H-T)/generic_clock.c‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,28 @@
2121
*/
2222
WEAK void SystemClock_Config(void)
2323
{
24-
/* SystemClock_Config can be generated by STM32CubeMX */
25-
#warning "SystemClock_Config() is empty. Default clock at reset is used."
24+
RCC_ClkInitTypeDef RCC_ClkInitStruct = {};
25+
RCC_PeriphCLKInitTypeDef PeriphClkInit = {};
26+
27+
/** Initializes the CPU, AHB and APB buses clocks
28+
*/
29+
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
30+
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
31+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
32+
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
33+
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
34+
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
35+
36+
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
37+
{
38+
Error_Handler();
39+
}
40+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
41+
PeriphClkInit.USBClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
42+
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
43+
{
44+
Error_Handler();
45+
}
2646
}
2747

2848
#endif /* ARDUINO_GENERIC_* */

0 commit comments

Comments
 (0)