rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions
STM32F4xx_System_Private_Functions
Collaboration diagram for STM32F4xx_System_Private_Functions:

Functions

void SystemInit (void)
 Setup the microcontroller system Initialize the FPU setting, vector table location and External memory configuration.
 
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.
 

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 stm32f4xx_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 stm32f4xx_hal_conf.h file (its value depends on the application requirements), 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 208 of file system_stm32f4xx.c.

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

◆ SystemInit()

void SystemInit ( void  )

Setup the microcontroller system Initialize the FPU setting, vector table location and External memory configuration.

Parameters
None
Return values
None

Definition at line 153 of file system_stm32f4xx.c.

154{
155 /* FPU settings ------------------------------------------------------------*/
156 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
157 SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
158 #endif
159
160#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
162#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
163
164 /* Configure the Vector Table location add offset address ------------------*/
165#ifdef VECT_TAB_SRAM
166 SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
167#else
168 SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
169#endif
170}
static void SystemInit_ExtMemCtl(void)
Setup the external memory controller. Called in startup_stm32f4xx.s before jump to main....

Referenced by __early_init().

Here is the call graph for this function:
Here is the caller graph for this function: