System Configuration functions.
More...
System Configuration functions.
===============================================================================
##### System Configuration functions #####
===============================================================================
[..]
System, AHB and APB buses clocks configuration
(+) The maximum frequency of the SYSCLK, HCLK, PCLK1 and PCLK2 is
120000000 Hz for STM32L4Rx/STM32L4Sx devices and 80000000 Hz for others.
◆ LL_PLL_ConfigSystemClock_HSE()
This function configures system clock with HSE as clock source of the PLL.
- Note
- The application need to ensure that PLL, PLLSAI1 and/or PLLSAI2 are disabled.
-
Function is based on the following formula:
- PLL output frequency = (((HSE frequency / PLLM) * PLLN) / PLLR)
- PLLM: ensure that the VCO input frequency ranges from 4 to 16 MHz (PLLVCO_input = HSE frequency / PLLM)
- PLLN: ensure that the VCO output frequency is between 64 and 344 MHz (PLLVCO_output = PLLVCO_input * PLLN)
- PLLR: ensure that max frequency at 120000000 Hz is reached (PLLVCO_output / PLLR)
- Parameters
-
| HSEFrequency | Value between Min_Data = 4000000 and Max_Data = 48000000 |
| HSEBypass | This parameter can be one of the following values:
- LL_UTILS_HSEBYPASS_ON
- LL_UTILS_HSEBYPASS_OFF
|
| UTILS_PLLInitStruct | pointer to a LL_UTILS_PLLInitTypeDef structure that contains the configuration information for the PLL. |
| UTILS_ClkInitStruct | pointer to a LL_UTILS_ClkInitTypeDef structure that contains the configuration information for the BUS prescalers. |
- Return values
-
| An | ErrorStatus enumeration value:
- SUCCESS: Max frequency configuration done
- ERROR: Max frequency configuration not done
|
Definition at line 507 of file stm32l4xx_ll_utils.c.
512 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 530 if(HSEBypass == LL_UTILS_HSEBYPASS_ON)
549 UTILS_PLLInitStruct->
PLLR);
551 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 553 if(pllfreq > 80000000U)
556 if(hpre == LL_RCC_SYSCLK_DIV_1)
565 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 567 if((status == SUCCESS) && (hpre != 0U))
__STATIC_INLINE void LL_RCC_HSE_Enable(void)
Enable HSE crystal oscillator (HSE ON) CR HSEON LL_RCC_HSE_Enable.
__STATIC_INLINE void LL_RCC_SetAHBPrescaler(uint32_t Prescaler)
Set AHB prescaler CFGR HPRE LL_RCC_SetAHBPrescaler.
__STATIC_INLINE void LL_RCC_HSE_DisableBypass(void)
Disable HSE external oscillator (HSE Bypass) CR HSEBYP LL_RCC_HSE_DisableBypass. ...
__STATIC_INLINE void LL_RCC_HSE_EnableBypass(void)
Enable HSE external oscillator (HSE Bypass) CR HSEBYP LL_RCC_HSE_EnableBypass.
static uint32_t UTILS_GetPLLOutputFrequency(uint32_t PLL_InputFrequency, LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct)
Function to check that PLL can be modified.
__STATIC_INLINE void LL_RCC_PLL_ConfigDomain_SYS(uint32_t Source, uint32_t PLLM, uint32_t PLLN, uint32_t PLLR)
Configure PLL used for SYSCLK Domain.
static ErrorStatus UTILS_PLL_IsBusy(void)
Function to check that PLL can be modified.
__STATIC_INLINE uint32_t LL_RCC_HSE_IsReady(void)
Check if HSE oscillator Ready CR HSERDY LL_RCC_HSE_IsReady.
static ErrorStatus UTILS_EnablePLLAndSwitchSystem(uint32_t SYSCLK_Frequency, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct)
Function to enable PLL and switch system clock to PLL.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
◆ LL_PLL_ConfigSystemClock_HSI()
This function configures system clock at maximum frequency with HSI as clock source of the PLL.
- Note
- The application need to ensure that PLL, PLLSAI1 and/or PLLSAI2 are disabled.
-
Function is based on the following formula:
- PLL output frequency = (((HSI frequency / PLLM) * PLLN) / PLLR)
- PLLM: ensure that the VCO input frequency ranges from 4 to 16 MHz (PLLVCO_input = HSI frequency / PLLM)
- PLLN: ensure that the VCO output frequency is between 64 and 344 MHz (PLLVCO_output = PLLVCO_input * PLLN)
- PLLR: ensure that max frequency at 120000000 Hz is reach (PLLVCO_output / PLLR)
- Parameters
-
| UTILS_PLLInitStruct | pointer to a LL_UTILS_PLLInitTypeDef structure that contains the configuration information for the PLL. |
| UTILS_ClkInitStruct | pointer to a LL_UTILS_ClkInitTypeDef structure that contains the configuration information for the BUS prescalers. |
- Return values
-
| An | ErrorStatus enumeration value:
- SUCCESS: Max frequency configuration done
- ERROR: Max frequency configuration not done
|
Definition at line 426 of file stm32l4xx_ll_utils.c.
431 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 453 UTILS_PLLInitStruct->
PLLR);
455 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 457 if(pllfreq > 80000000U)
460 if(hpre == LL_RCC_SYSCLK_DIV_1)
469 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 471 if((status == SUCCESS) && (hpre != 0U))
__STATIC_INLINE uint32_t LL_RCC_HSI_IsReady(void)
Check if HSI clock is ready CR HSIRDY LL_RCC_HSI_IsReady.
__STATIC_INLINE void LL_RCC_SetAHBPrescaler(uint32_t Prescaler)
Set AHB prescaler CFGR HPRE LL_RCC_SetAHBPrescaler.
__STATIC_INLINE void LL_RCC_HSI_Enable(void)
Enable HSI oscillator CR HSION LL_RCC_HSI_Enable.
static uint32_t UTILS_GetPLLOutputFrequency(uint32_t PLL_InputFrequency, LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct)
Function to check that PLL can be modified.
__STATIC_INLINE void LL_RCC_PLL_ConfigDomain_SYS(uint32_t Source, uint32_t PLLM, uint32_t PLLN, uint32_t PLLR)
Configure PLL used for SYSCLK Domain.
static ErrorStatus UTILS_PLL_IsBusy(void)
Function to check that PLL can be modified.
static ErrorStatus UTILS_EnablePLLAndSwitchSystem(uint32_t SYSCLK_Frequency, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct)
Function to enable PLL and switch system clock to PLL.
◆ LL_PLL_ConfigSystemClock_MSI()
This function configures system clock with MSI as clock source of the PLL.
- Note
- The application needs to ensure that PLL, PLLSAI1 and/or PLLSAI2 are disabled.
-
Function is based on the following formula:
- PLL output frequency = (((MSI frequency / PLLM) * PLLN) / PLLR)
- PLLM: ensure that the VCO input frequency ranges from 4 to 16 MHz (PLLVCO_input = MSI frequency / PLLM)
- PLLN: ensure that the VCO output frequency is between 64 and 344 MHz (PLLVCO_output = PLLVCO_input * PLLN)
- PLLR: ensure that max frequency at 120000000 Hz is reached (PLLVCO_output / PLLR)
- Parameters
-
| UTILS_PLLInitStruct | pointer to a LL_UTILS_PLLInitTypeDef structure that contains the configuration information for the PLL. |
| UTILS_ClkInitStruct | pointer to a LL_UTILS_ClkInitTypeDef structure that contains the configuration information for the BUS prescalers. |
- Return values
-
| An | ErrorStatus enumeration value:
- SUCCESS: Max frequency configuration done
- ERROR: Max frequency configuration not done
|
Definition at line 300 of file stm32l4xx_ll_utils.c.
303 ErrorStatus status = SUCCESS;
304 uint32_t pllfreq, msi_range;
305 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 318 case LL_RCC_MSIRANGE_0:
319 case LL_RCC_MSIRANGE_1:
320 case LL_RCC_MSIRANGE_2:
321 case LL_RCC_MSIRANGE_3:
322 case LL_RCC_MSIRANGE_4:
323 case LL_RCC_MSIRANGE_5:
328 case LL_RCC_MSIRANGE_6:
329 case LL_RCC_MSIRANGE_7:
330 case LL_RCC_MSIRANGE_8:
331 case LL_RCC_MSIRANGE_9:
332 case LL_RCC_MSIRANGE_10:
333 case LL_RCC_MSIRANGE_11:
343 case LL_RCC_MSISRANGE_4:
344 case LL_RCC_MSISRANGE_5:
349 case LL_RCC_MSISRANGE_7:
350 case LL_RCC_MSISRANGE_6:
361 UTILS_PLLInitStruct);
375 UTILS_PLLInitStruct->
PLLR);
377 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 379 if(pllfreq > 80000000U)
382 if(hpre == LL_RCC_SYSCLK_DIV_1)
391 #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 393 if((status == SUCCESS) && (hpre != 0U))
__STATIC_INLINE void LL_RCC_SetAHBPrescaler(uint32_t Prescaler)
Set AHB prescaler CFGR HPRE LL_RCC_SetAHBPrescaler.
__STATIC_INLINE uint32_t LL_RCC_MSI_GetRangeAfterStandby(void)
Get MSI range used after standby CSR MSISRANGE LL_RCC_MSI_GetRangeAfterStandby.
__STATIC_INLINE uint32_t LL_RCC_MSI_IsReady(void)
Check if MSI oscillator Ready CR MSIRDY LL_RCC_MSI_IsReady.
__STATIC_INLINE uint32_t LL_RCC_MSI_IsEnabledRangeSelect(void)
Check if MSI clock range is selected with MSIRANGE register CR MSIRGSEL LL_RCC_MSI_IsEnabledRangeSel...
__STATIC_INLINE void LL_RCC_MSI_Enable(void)
Enable MSI oscillator CR MSION LL_RCC_MSI_Enable.
static uint32_t UTILS_GetPLLOutputFrequency(uint32_t PLL_InputFrequency, LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct)
Function to check that PLL can be modified.
__STATIC_INLINE void LL_RCC_PLL_ConfigDomain_SYS(uint32_t Source, uint32_t PLLM, uint32_t PLLN, uint32_t PLLR)
Configure PLL used for SYSCLK Domain.
static ErrorStatus UTILS_PLL_IsBusy(void)
Function to check that PLL can be modified.
__STATIC_INLINE uint32_t LL_RCC_MSI_GetRange(void)
Get the Internal Multi Speed oscillator (MSI) clock range in run mode. CR MSIRANGE LL_RCC_MSI_GetRan...
static ErrorStatus UTILS_EnablePLLAndSwitchSystem(uint32_t SYSCLK_Frequency, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct)
Function to enable PLL and switch system clock to PLL.
◆ LL_SetSystemCoreClock()
| void LL_SetSystemCoreClock |
( |
uint32_t |
HCLKFrequency | ) |
|
This function sets directly SystemCoreClock CMSIS variable.
- Note
- Variable can be calculated also through SystemCoreClockUpdate function.
- Parameters
-
| HCLKFrequency | HCLK frequency in Hz (can be calculated thanks to RCC helper macro) |
- Return values
-
Definition at line 278 of file stm32l4xx_ll_utils.c.
281 SystemCoreClock = HCLKFrequency;