Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 6 | ||
---|---|---|---|
Line 16... | Line 16... | ||
16 | * |
16 | * |
17 | * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must |
17 | * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must |
18 | * be called whenever the core clock is changed |
18 | * be called whenever the core clock is changed |
19 | * during program execution. |
19 | * during program execution. |
20 | * |
20 | * |
21 | * 2. After each device reset the HSI (8 MHz) is used as system clock source. |
- | |
22 | * Then SystemInit() function is called, in "startup_stm32f0xx.s" file, to |
- | |
23 | * configure the system clock before to branch to main program. |
- | |
24 | * |
21 | * |
25 | * 3. This file configures the system clock as follows: |
- | |
26 | *============================================================================= |
- | |
27 | * Supported STM32F0xx device |
- | |
28 | *----------------------------------------------------------------------------- |
- | |
29 | * System Clock source | HSI |
- | |
30 | *----------------------------------------------------------------------------- |
- | |
31 | * SYSCLK(Hz) | 8000000 |
- | |
32 | *----------------------------------------------------------------------------- |
- | |
33 | * HCLK(Hz) | 8000000 |
- | |
34 | *----------------------------------------------------------------------------- |
- | |
35 | * AHB Prescaler | 1 |
- | |
36 | *----------------------------------------------------------------------------- |
- | |
37 | * APB1 Prescaler | 1 |
- | |
38 | *----------------------------------------------------------------------------- |
- | |
39 | *============================================================================= |
- | |
40 | ****************************************************************************** |
22 | ****************************************************************************** |
41 | * @attention |
23 | * @attention |
42 | * |
24 | * |
43 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
25 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
44 | * All rights reserved.</center></h2> |
26 | * All rights reserved.</center></h2> |
Line 111... | Line 93... | ||
111 | */ |
93 | */ |
112 | /* This variable is updated in three ways: |
94 | /* This variable is updated in three ways: |
113 | 1) by calling CMSIS function SystemCoreClockUpdate() |
95 | 1) by calling CMSIS function SystemCoreClockUpdate() |
114 | 2) by calling HAL API function HAL_RCC_GetHCLKFreq() |
96 | 2) by calling HAL API function HAL_RCC_GetHCLKFreq() |
115 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency |
97 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency |
116 | Note: If you use this function to configure the system clock there is no need to |
98 | Note: If you use this function to configure the system clock; then there |
117 | call the 2 first functions listed above, since SystemCoreClock variable is |
99 | is no need to call the 2 first functions listed above, since SystemCoreClock |
118 | updated automatically. |
100 | variable is updated automatically. |
119 | */ |
101 | */ |
120 | uint32_t SystemCoreClock = 8000000; |
102 | uint32_t SystemCoreClock = 8000000; |
121 | 103 | ||
122 | const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; |
104 | const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9}; |
123 | const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; |
105 | const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4}; |
Line 137... | Line 119... | ||
137 | /** @addtogroup STM32F0xx_System_Private_Functions |
119 | /** @addtogroup STM32F0xx_System_Private_Functions |
138 | * @{ |
120 | * @{ |
139 | */ |
121 | */ |
140 | 122 | ||
141 | /** |
123 | /** |
142 | * @brief Setup the microcontroller system. |
124 | * @brief Setup the microcontroller system |
143 | * @param None |
125 | * @param None |
144 | * @retval None |
126 | * @retval None |
145 | */ |
127 | */ |
146 | void SystemInit(void) |
128 | void SystemInit(void) |
147 | { |
129 | { |
Line 172... | Line 154... | ||
172 | * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) |
154 | * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**) |
173 | * |
155 | * |
174 | * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) |
156 | * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) |
175 | * or HSI_VALUE(*) multiplied/divided by the PLL factors. |
157 | * or HSI_VALUE(*) multiplied/divided by the PLL factors. |
176 | * |
158 | * |
177 | * (*) HSI_VALUE is a constant defined in stm32f0xx_hal.h file (default value |
159 | * (*) HSI_VALUE is a constant defined in stm32f0xx_hal_conf.h file (default value |
178 | * 8 MHz) but the real value may vary depending on the variations |
160 | * 8 MHz) but the real value may vary depending on the variations |
179 | * in voltage and temperature. |
161 | * in voltage and temperature. |
180 | * |
162 | * |
181 | * (**) HSE_VALUE is a constant defined in stm32f0xx_hal.h file (default value |
163 | * (**) HSE_VALUE is a constant defined in stm32f0xx_hal_conf.h file (its value |
182 | * 8 MHz), user has to ensure that HSE_VALUE is same as the real |
164 | * depends on the application requirements), user has to ensure that HSE_VALUE |
183 | * frequency of the crystal used. Otherwise, this function may |
165 | * is same as the real frequency of the crystal used. Otherwise, this function |
184 | * have wrong result. |
166 | * may have wrong result. |
185 | * |
167 | * |
186 | * - The result of this function could be not correct when using fractional |
168 | * - The result of this function could be not correct when using fractional |
187 | * value for HSE crystal. |
169 | * value for HSE crystal. |
188 | * |
170 | * |
189 | * @param None |
171 | * @param None |