embox

Форк
0
75 строк · 2.7 Кб
1
/**
2
 * @file
3
 * @brief
4
 *
5
 * @author  Anton Kozlov
6
 * @date    30.10.2014
7
 */
8

9
#include <bsp/stm32cube_hal.h>
10

11
/**
12
  * @brief  System Clock Configuration
13
  *         The system Clock is configured as follow : 
14
  *            System Clock source            = PLL (HSI)
15
  *            SYSCLK(Hz)                     = 100000000
16
  *            HCLK(Hz)                       = 100000000
17
  *            AHB Prescaler                  = 1
18
  *            APB1 Prescaler                 = 2
19
  *            APB2 Prescaler                 = 1
20
  *            HSI Frequency(Hz)              = 16000000
21
  *            PLL_M                          = 16
22
  *            PLL_N                          = 200
23
  *            PLL_P                          = 2
24
  *            PLL_Q                          = 15
25
  *            PLL_R                          = 7
26
  *            VDD(V)                         = 3.3
27
  *            Main regulator output voltage  = Scale1 mode
28
  *            Flash Latency(WS)              = 5
29
  * @param  None
30
  * @retval None
31
  */
32
void SystemClock_Config(void) {
33
	RCC_ClkInitTypeDef RCC_ClkInitStruct;
34
	RCC_OscInitTypeDef RCC_OscInitStruct;
35

36
	/* Enable Power Control clock */
37
	__HAL_RCC_PWR_CLK_ENABLE();
38

39
	/* The voltage scaling allows optimizing the power consumption when the device is 
40
     clocked below the maximum system frequency, to update the voltage scaling value 
41
     regarding system frequency refer to product datasheet.  */
42
	__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
43

44
	/* Enable HSI Oscillator and activate PLL with HSI as source */
45
	RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
46
	RCC_OscInitStruct.HSIState = RCC_HSI_ON;
47
	RCC_OscInitStruct.HSICalibrationValue = 0x10;
48
	RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
49
	RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
50
	RCC_OscInitStruct.PLL.PLLM = 16;
51
	RCC_OscInitStruct.PLL.PLLN = 200;
52
	RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
53
	RCC_OscInitStruct.PLL.PLLQ = 15;
54
	RCC_OscInitStruct.PLL.PLLR = 7;
55

56
	if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
57
		/* Initialization Error */
58
		while (1)
59
			;
60
	}
61

62
	/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 
63
     clocks dividers */
64
	RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK
65
	                               | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
66
	RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
67
	RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
68
	RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
69
	RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
70
	if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) {
71
		/* Initialization Error */
72
		while (1)
73
			;
74
	}
75
}
76

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.