Prusa MINI Firmware overview
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. 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

◆ SystemInit()

void SystemInit ( void  )

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

Parameters
None
Return values
None
237  {

◆ 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
243  {
244  case 0x00: /* HSI used as system clock source */
246  break;
247  case 0x04: /* HSE used as system clock source */
249  break;
250  case 0x08: /* PLL used as system clock source */
251 
252  /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
253  SYSCLK = PLL_VCO / PLL_P
254  */
255  pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
256  pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
257 
258  if (pllsource != 0) {
259  /* HSE used as PLL clock source */
260  pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
261  } else {
262  /* HSI used as PLL clock source */
263  pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
264  }
265 
266  pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >> 16) + 1) * 2;
267  SystemCoreClock = pllvco / pllp;
268  break;
269  default:
271  break;
272  }
273  /* Compute HCLK frequency --------------------------------------------------*/
274  /* Get HCLK prescaler */
275  tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
276  /* HCLK frequency */
277  SystemCoreClock >>= tmp;
278 }
279 
SystemCoreClock
uint32_t SystemCoreClock
Definition: system_stm32f4xx.c:136
HSE_VALUE
#define HSE_VALUE
Definition: system_stm32f4xx.c:67
HSI_VALUE
#define HSI_VALUE
Definition: system_stm32f4xx.c:71
AHBPrescTable
const uint8_t AHBPrescTable[16]
Definition: system_stm32f4xx.c:137