Sysclock configuration.
More...
#include "../includes/config.h"
#include "Arduino.h"
Go to the source code of this file.
Sysclock configuration.
- Author
- Makers For Life
- Copyright
- Copyright (c) 2020 Makers For Life
Definition in file sysclock.cpp.
◆ SystemClock_Config()
void SystemClock_Config |
( |
void |
| ) |
|
System Clock Configuration, for hardware v3 and later on.
- Note
- SYSCLK = 100000000 Hz for STM32F411xE
Configure the main internal regulator output voltage
Initializes the CPU, AHB and APB busses clocks
Initializes the CPU, AHB and APB busses clocks
Definition at line 22 of file sysclock.cpp.
23 RCC_OscInitTypeDef RCC_OscInitStruct = {0};
24 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
28 __HAL_RCC_PWR_CLK_ENABLE();
29 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
32 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
33 RCC_OscInitStruct.HSEState = RCC_HSE_ON;
34 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
35 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
36 RCC_OscInitStruct.PLL.PLLM = 4;
37 RCC_OscInitStruct.PLL.PLLN = 100;
38 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
39 RCC_OscInitStruct.PLL.PLLQ = 4;
40 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
45 RCC_ClkInitStruct.ClockType =
46 RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
47 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
48 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
49 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
50 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
52 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) {