4
4
* @author MCD Application Team
5
5
* @brief CMSIS Cortex-Mx Device Peripheral Access Layer System Source File.
6
6
*
7
- * This file provides two functions and one global variable to be called from
7
+ * This file provides two functions and one global variable to be called from
8
8
* user application:
9
- * - SystemInit(): This function is called at startup just after reset and
9
+ * - SystemInit(): This function is called at startup just after reset and
10
10
* before branch to main program. This call is made inside
11
11
* the "startup_stm32h7xx.s" file.
12
12
*
13
13
* - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
14
- * by the user application to setup the SysTick
14
+ * by the user application to setup the SysTick
15
15
* timer or configure other parameters.
16
- *
16
+ *
17
17
* - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
18
18
* be called whenever the core clock is changed
19
19
* during program execution.
39
39
40
40
/** @addtogroup stm32h7xx_system
41
41
* @{
42
- */
43
-
42
+ */
43
+
44
44
/** @addtogroup STM32H7xx_System_Private_Includes
45
45
* @{
46
46
*/
107
107
/* This variable is updated in three ways:
108
108
1) by calling CMSIS function SystemCoreClockUpdate()
109
109
2) by calling HAL API function HAL_RCC_GetHCLKFreq()
110
- 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
110
+ 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
111
111
Note: If you use this function to configure the system clock; then there
112
112
is no need to call the 2 first functions listed above, since SystemCoreClock
113
113
variable is updated automatically.
140
140
* @retval None
141
141
*/
142
142
void SystemInit (void )
143
- {
143
+ {
144
144
#if defined (DATA_IN_D2_SRAM )
145
145
__IO uint32_t tmpreg ;
146
146
#endif /* DATA_IN_D2_SRAM */
@@ -152,7 +152,7 @@ void SystemInit (void)
152
152
/* Reset the RCC clock configuration to the default reset state ------------*/
153
153
/* Set HSION bit */
154
154
RCC -> CR |= RCC_CR_HSION ;
155
-
155
+
156
156
/* Reset CFGR register */
157
157
RCC -> CFGR = 0x00000000 ;
158
158
@@ -164,7 +164,7 @@ void SystemInit (void)
164
164
165
165
/* Reset D2CFGR register */
166
166
RCC -> D2CFGR = 0x00000000 ;
167
-
167
+
168
168
/* Reset D3CFGR register */
169
169
RCC -> D3CFGR = 0x00000000 ;
170
170
@@ -182,14 +182,14 @@ void SystemInit (void)
182
182
RCC -> PLL2DIVR = 0x00000000 ;
183
183
184
184
/* Reset PLL2FRACR register */
185
-
185
+
186
186
RCC -> PLL2FRACR = 0x00000000 ;
187
187
/* Reset PLL3DIVR register */
188
188
RCC -> PLL3DIVR = 0x00000000 ;
189
189
190
190
/* Reset PLL3FRACR register */
191
191
RCC -> PLL3FRACR = 0x00000000 ;
192
-
192
+
193
193
/* Reset HSEBYP bit */
194
194
RCC -> CR &= 0xFFFBFFFFU ;
195
195
@@ -221,7 +221,7 @@ void SystemInit (void)
221
221
if ((DBGMCU -> IDCODE & 0xFFFF0000U ) < 0x20000000U )
222
222
{
223
223
/* if stm32h7 revY*/
224
- /* Change the switch matrix read issuing capability to 1 for the AXI SRAM target (Target 7) */
224
+ /* Change the switch matrix read issuing capability to 1 for the AXI SRAM target (Target 7) */
225
225
* ((__IO uint32_t * )0x51008108 ) = 0x000000001U ;
226
226
}
227
227
@@ -230,7 +230,7 @@ void SystemInit (void)
230
230
SCB -> VTOR = D1_AXISRAM_BASE | VECT_TAB_OFFSET ; /* Vector Table Relocation in Internal D1 AXI-RAM */
231
231
#else
232
232
SCB -> VTOR = NVIC_FLASH_VECTOR_ADDRESS ; /* Vector Table Relocation in Internal FLASH */ // MBED PATCH for Bootloader
233
- #endif
233
+ #endif
234
234
235
235
#endif /*DUAL_CORE && CORE_CM4*/
236
236
@@ -241,33 +241,33 @@ void SystemInit (void)
241
241
* The SystemCoreClock variable contains the core clock , it can
242
242
* be used by the user application to setup the SysTick timer or configure
243
243
* other parameters.
244
- *
244
+ *
245
245
* @note Each time the core clock changes, this function must be called
246
246
* to update SystemCoreClock variable value. Otherwise, any configuration
247
- * based on this variable will be incorrect.
248
- *
249
- * @note - The system frequency computed by this function is not the real
250
- * frequency in the chip. It is calculated based on the predefined
247
+ * based on this variable will be incorrect.
248
+ *
249
+ * @note - The system frequency computed by this function is not the real
250
+ * frequency in the chip. It is calculated based on the predefined
251
251
* constant and the selected clock source:
252
- *
253
- * - If SYSCLK source is CSI, SystemCoreClock will contain the CSI_VALUE(*)
252
+ *
253
+ * - If SYSCLK source is CSI, SystemCoreClock will contain the CSI_VALUE(*)
254
254
* - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**)
255
- * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***)
255
+ * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***)
256
256
* - If SYSCLK source is PLL, SystemCoreClock will contain the CSI_VALUE(*),
257
257
* HSI_VALUE(**) or HSE_VALUE(***) multiplied/divided by the PLL factors.
258
258
*
259
259
* (*) CSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value
260
260
* 4 MHz) but the real value may vary depending on the variations
261
- * in voltage and temperature.
261
+ * in voltage and temperature.
262
262
* (**) HSI_VALUE is a constant defined in stm32h7xx_hal.h file (default value
263
263
* 64 MHz) but the real value may vary depending on the variations
264
- * in voltage and temperature.
265
- *
264
+ * in voltage and temperature.
265
+ *
266
266
* (***)HSE_VALUE is a constant defined in stm32h7xx_hal.h file (default value
267
267
* 25 MHz), user has to ensure that HSE_VALUE is same as the real
268
268
* frequency of the crystal used. Otherwise, this function may
269
269
* have wrong result.
270
- *
270
+ *
271
271
* - The result of this function could be not correct when using fractional
272
272
* value for HSE crystal.
273
273
* @param None
@@ -283,7 +283,7 @@ void SystemCoreClockUpdate (void)
283
283
switch (RCC -> CFGR & RCC_CFGR_SWS )
284
284
{
285
285
case RCC_CFGR_SWS_HSI : /* HSI used as system clock source */
286
- SystemCoreClock = (uint32_t ) (HSI_VALUE >> ((RCC -> CR & RCC_CR_HSIDIV )>> 3 ));
286
+ SystemCoreClock = (uint32_t ) (HSI_VALUE >> ((RCC -> CR & RCC_CR_HSIDIV )>> 3 ));
287
287
break ;
288
288
289
289
case RCC_CFGR_SWS_CSI : /* CSI used as system clock source */
@@ -306,27 +306,27 @@ void SystemCoreClockUpdate (void)
306
306
307
307
if (pllm != 0U )
308
308
{
309
- switch (pllsource )
310
- {
309
+ switch (pllsource )
310
+ {
311
311
case RCC_PLLCKSELR_PLLSRC_HSI : /* HSI used as PLL clock source */
312
312
313
- hsivalue = (HSI_VALUE >> ((RCC -> CR & RCC_CR_HSIDIV )>> 3 )) ;
313
+ hsivalue = (HSI_VALUE >> ((RCC -> CR & RCC_CR_HSIDIV )>> 3 )) ;
314
314
pllvco = ( (float_t )hsivalue / (float_t )pllm ) * ((float_t )(uint32_t )(RCC -> PLL1DIVR & RCC_PLL1DIVR_N1 ) + (fracn1 /(float_t )0x2000 ) + (float_t )1 );
315
315
316
- break ;
316
+ break ;
317
317
318
318
case RCC_PLLCKSELR_PLLSRC_CSI : /* CSI used as PLL clock source */
319
319
pllvco = ((float_t )CSI_VALUE / (float_t )pllm ) * ((float_t )(uint32_t )(RCC -> PLL1DIVR & RCC_PLL1DIVR_N1 ) + (fracn1 /(float_t )0x2000 ) + (float_t )1 );
320
- break ;
320
+ break ;
321
321
322
322
case RCC_PLLCKSELR_PLLSRC_HSE : /* HSE used as PLL clock source */
323
323
pllvco = ((float_t )HSE_VALUE / (float_t )pllm ) * ((float_t )(uint32_t )(RCC -> PLL1DIVR & RCC_PLL1DIVR_N1 ) + (fracn1 /(float_t )0x2000 ) + (float_t )1 );
324
- break ;
324
+ break ;
325
325
326
- default :
326
+ default :
327
327
pllvco = ((float_t )CSI_VALUE / (float_t )pllm ) * ((float_t )(uint32_t )(RCC -> PLL1DIVR & RCC_PLL1DIVR_N1 ) + (fracn1 /(float_t )0x2000 ) + (float_t )1 );
328
- break ;
329
- }
328
+ break ;
329
+ }
330
330
pllp = (((RCC -> PLL1DIVR & RCC_PLL1DIVR_P1 ) >>9 ) + 1U ) ;
331
331
SystemCoreClock = (uint32_t )(float_t )(pllvco /(float_t )pllp );
332
332
}
@@ -340,7 +340,7 @@ void SystemCoreClockUpdate (void)
340
340
SystemCoreClock = CSI_VALUE ;
341
341
break ;
342
342
}
343
-
343
+
344
344
/* Compute SystemClock frequency --------------------------------------------------*/
345
345
tmp = D1CorePrescTable [(RCC -> D1CFGR & RCC_D1CFGR_D1CPRE )>> RCC_D1CFGR_D1CPRE_Pos ];
346
346
@@ -351,7 +351,7 @@ void SystemCoreClockUpdate (void)
351
351
SystemD2Clock = (SystemCoreClock >> ((D1CorePrescTable [(RCC -> D1CFGR & RCC_D1CFGR_HPRE )>> RCC_D1CFGR_HPRE_Pos ]) & 0x1FU ));
352
352
353
353
}
354
-
354
+
355
355
356
356
/**
357
357
* @}
0 commit comments