Vehicle Control Unit 0.01
This is the c library for controlling the car.
Loading...
Searching...
No Matches
Functions
STM32F7xx_System_Private_Functions
Collaboration diagram for STM32F7xx_System_Private_Functions:

Functions

void SystemInit (void)
 Setup the microcontroller system Initialize the Embedded Flash Interface, the PLL and update the SystemFrequency variable. More...
 
void SystemCoreClockUpdate (void)
 Update SystemCoreClock variable according to Clock Register Values. The SystemCoreClock variable contains the core clock (HCLK), it can be used by the user application to setup the SysTick timer or configure other parameters. More...
 

Detailed Description

Function Documentation

◆ SystemCoreClockUpdate()

void SystemCoreClockUpdate ( void  )

Update SystemCoreClock variable according to Clock Register Values. The SystemCoreClock variable contains the core clock (HCLK), it can be used by the user application to setup the SysTick timer or configure other parameters.

Note
Each time the core clock (HCLK) changes, this function must be called to update SystemCoreClock variable value. Otherwise, any configuration based on this variable will be incorrect.
- The system frequency computed by this function is not the real frequency in the chip. It is calculated based on the predefined constant and the selected clock source:
  • If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
  • If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
  • If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) or HSI_VALUE(*) multiplied/divided by the PLL factors.

(*) HSI_VALUE is a constant defined in stm32f7xx_hal_conf.h file (default value 16 MHz) but the real value may vary depending on the variations in voltage and temperature.

(**) HSE_VALUE is a constant defined in stm32f7xx_hal_conf.h file (default value 25 MHz), user has to ensure that HSE_VALUE is same as the real frequency of the crystal used. Otherwise, this function may have wrong result.

  • The result of this function could be not correct when using fractional value for HSE crystal.
Parameters
None
Return values
None

Definition at line 200 of file system_stm32f7xx.c.

201{
202 uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
203
204 /* Get SYSCLK source -------------------------------------------------------*/
205 tmp = RCC->CFGR & RCC_CFGR_SWS;
206
207 switch (tmp)
208 {
209 case 0x00: /* HSI used as system clock source */
211 break;
212 case 0x04: /* HSE used as system clock source */
214 break;
215 case 0x08: /* PLL used as system clock source */
216
217 /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
218 SYSCLK = PLL_VCO / PLL_P
219 */
220 pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
221 pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
222
223 if (pllsource != 0)
224 {
225 /* HSE used as PLL clock source */
226 pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
227 }
228 else
229 {
230 /* HSI used as PLL clock source */
231 pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
232 }
233
234 pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;
235 SystemCoreClock = pllvco/pllp;
236 break;
237 default:
239 break;
240 }
241 /* Compute HCLK frequency --------------------------------------------------*/
242 /* Get HCLK prescaler */
243 tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
244 /* HCLK frequency */
245 SystemCoreClock >>= tmp;
246}
#define HSI_VALUE
#define HSE_VALUE
const uint8_t AHBPrescTable[16]
uint32_t SystemCoreClock

◆ SystemInit()

void SystemInit ( void  )

Setup the microcontroller system Initialize the Embedded Flash Interface, the PLL and update the SystemFrequency variable.

Parameters
None
Return values
None

Definition at line 151 of file system_stm32f7xx.c.

152{
153 /* FPU settings ------------------------------------------------------------*/
154#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
155 SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
156#endif
157
158 /* Configure the Vector Table location -------------------------------------*/
159#if defined(USER_VECT_TAB_ADDRESS)
160 SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
161#endif /* USER_VECT_TAB_ADDRESS */
162}