STM32 Bootloader
Customizable Bootloader for STM32 microcontrollers
STM32L4xx_System

Macros

#define HSE_VALUE   8000000U
 
#define MSI_VALUE   4000000U
 
#define HSI_VALUE   16000000U
 

Functions

void SystemInit (void)
 Initialize the system before calling the main() function.
 
void SystemCoreClockUpdate (void)
 Update the SystemCoreClock variable according to the clock register values. More...
 

Variables

uint32_t SystemCoreClock = 4000000U
 Define to enable user-defined vector table address setting. More...
 
const uint8_t AHBPrescTable [16]
 
const uint8_t APBPrescTable [8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}
 
const uint32_t MSIRangeTable [12]
 

Detailed Description

Macro Definition Documentation

◆ HSE_VALUE

#define HSE_VALUE   8000000U

Value of the external oscillator in Hz

Definition at line 68 of file system_stm32l4xx.c.

◆ HSI_VALUE

#define HSI_VALUE   16000000U

Value of the internal oscillator (HSI) in Hz

Definition at line 78 of file system_stm32l4xx.c.

◆ MSI_VALUE

#define MSI_VALUE   4000000U

Value of the internal oscillator (MSI) in Hz

Definition at line 73 of file system_stm32l4xx.c.

Function Documentation

◆ SystemCoreClockUpdate()

void SystemCoreClockUpdate ( void  )

Update the SystemCoreClock variable according to the 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.

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 MSI, SystemCoreClock will contain the MSI_VALUE (*)
  • 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 (*) or MSI_VALUE (*) multiplied/divided by the PLL factors.

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

(**) HSI_VALUE is a constant defined in stm32l4xx_hal.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 stm32l4xx_hal.h file (default value 8 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.

Note
The result of this function could be not correct when using fractional value for HSE crystal.

Definition at line 200 of file system_stm32l4xx.c.

Variable Documentation

◆ AHBPrescTable

const uint8_t AHBPrescTable[16]
Initial value:
= {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U,
1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}

The AHB prescaler values.

Definition at line 136 of file system_stm32l4xx.c.

◆ APBPrescTable

const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}

The APB prescaler values.

Definition at line 140 of file system_stm32l4xx.c.

◆ MSIRangeTable

const uint32_t MSIRangeTable[12]
Initial value:
= {100000U, 200000U, 400000U, 800000U,
1000000U, 2000000U, 4000000U, 8000000U,
16000000U, 24000000U, 32000000U, 48000000U}

The MSI iscillator values values.

Definition at line 143 of file system_stm32l4xx.c.

◆ SystemCoreClock

uint32_t SystemCoreClock = 4000000U

Define to enable user-defined vector table address setting.

Uncomment the following line if you need to relocate the vector table anywhere in Flash or SRAM, else the vector table is kept at the automatic remap of the boot address selected.

Note
The vector table addresses must be defined in line with the linker configuration.

The system core clock value in Hz.

The SystemCoreClock variable is updated in three ways:

  1. By calling CMSIS function SystemCoreClockUpdate().
  2. By calling HAL API function HAL_RCC_GetHCLKFreq().
  3. Each time HAL_RCC_ClockConfig() is called to configure the system clock frequency.
Note
If you use this function to configure the system clock; then there is no need to call the first two functions listed above, because the SystemCoreClock variable is updated automatically.

Definition at line 133 of file system_stm32l4xx.c.