DIY Logging Volt/Ampmeter

System Configuration functions. More...

Functions

void LL_SetSystemCoreClock (uint32_t HCLKFrequency)
 This function sets directly SystemCoreClock CMSIS variable. More...
 
ErrorStatus LL_PLL_ConfigSystemClock_HSI (LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct)
 Update number of Flash wait states in line with new frequency and current voltage range. More...
 
ErrorStatus LL_PLL_ConfigSystemClock_HSE (uint32_t HSEFrequency, uint32_t HSEBypass, LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct)
 This function configures system clock with HSE as clock source of the PLL. More...
 

Detailed Description

System Configuration functions.

===============================================================================
          ##### System Configuration functions #####
===============================================================================
   [..]
        System, AHB and APB buses clocks configuration

        (+) The maximum frequency of the SYSCLK, HCLK, PCLK1 and PCLK2 is RCC_MAX_FREQUENCY Hz.

Function Documentation

◆ LL_PLL_ConfigSystemClock_HSE()

ErrorStatus LL_PLL_ConfigSystemClock_HSE ( uint32_t  HSEFrequency,
uint32_t  HSEBypass,
LL_UTILS_PLLInitTypeDef UTILS_PLLInitStruct,
LL_UTILS_ClkInitTypeDef UTILS_ClkInitStruct 
)

This function configures system clock with HSE as clock source of the PLL.

Note
The application need to ensure that PLL is disabled.
Function is based on the following formula:
  • PLL output frequency = ((HSI frequency / PREDIV) * PLLMUL)
  • PREDIV: Set to 2 for few devices
  • PLLMUL: The application software must set correctly the PLL multiplication factor to not exceed UTILS_PLL_OUTPUT_MAX
FLASH latency can be modified through this function.
Parameters
HSEFrequencyValue between Min_Data = RCC_HSE_MIN and Max_Data = RCC_HSE_MAX
HSEBypassThis parameter can be one of the following values:
UTILS_PLLInitStructpointer to a LL_UTILS_PLLInitTypeDef structure that contains the configuration information for the PLL.
UTILS_ClkInitStructpointer to a LL_UTILS_ClkInitTypeDef structure that contains the configuration information for the BUS prescalers.
Return values
AnErrorStatus enumeration value:
  • SUCCESS: Max frequency configuration done
  • ERROR: Max frequency configuration not done

Definition at line 399 of file stm32f1xx_ll_utils.c.

401 {
402  ErrorStatus status = SUCCESS;
403  uint32_t pllfreq = 0U;
404 
405  /* Check the parameters */
408 
409  /* Check if one of the PLL is enabled */
410  if (UTILS_PLL_IsBusy() == SUCCESS)
411  {
412  assert_param(IS_LL_UTILS_PREDIV_VALUE(UTILS_PLLInitStruct->Prediv));
413 
414  /* Calculate the new PLL output frequency */
415  pllfreq = UTILS_GetPLLOutputFrequency(HSEFrequency, UTILS_PLLInitStruct);
416 
417  /* Enable HSE if not enabled */
418  if (LL_RCC_HSE_IsReady() != 1U)
419  {
420  /* Check if need to enable HSE bypass feature or not */
421  if (HSEBypass == LL_UTILS_HSEBYPASS_ON)
422  {
423  LL_RCC_HSE_EnableBypass();
424  }
425  else
426  {
427  LL_RCC_HSE_DisableBypass();
428  }
429 
430  /* Enable HSE */
431  LL_RCC_HSE_Enable();
432  while (LL_RCC_HSE_IsReady() != 1U)
433  {
434  /* Wait for HSE ready */
435  }
436  }
437 
438  /* Configure PLL */
439  LL_RCC_PLL_ConfigDomain_SYS((RCC_CFGR_PLLSRC | UTILS_PLLInitStruct->Prediv), UTILS_PLLInitStruct->PLLMul);
440 
441  /* Enable PLL and switch system clock to PLL */
442  status = UTILS_EnablePLLAndSwitchSystem(pllfreq, UTILS_ClkInitStruct);
443  }
444  else
445  {
446  /* Current PLL configuration cannot be modified */
447  status = ERROR;
448  }
449 
450  return status;
451 }

◆ LL_PLL_ConfigSystemClock_HSI()

ErrorStatus LL_PLL_ConfigSystemClock_HSI ( LL_UTILS_PLLInitTypeDef UTILS_PLLInitStruct,
LL_UTILS_ClkInitTypeDef UTILS_ClkInitStruct 
)

Update number of Flash wait states in line with new frequency and current voltage range.

Parameters
FrequencySYSCLK frequency
Return values
AnErrorStatus enumeration value:
  • SUCCESS: Latency has been modified
  • ERROR: Latency cannot be modified

This function configures system clock with HSI as clock source of the PLL

Note
The application need to ensure that PLL is disabled.
Function is based on the following formula:
  • PLL output frequency = ((HSI frequency / PREDIV) * PLLMUL)
  • PREDIV: Set to 2 for few devices
  • PLLMUL: The application software must set correctly the PLL multiplication factor to not exceed 72MHz
FLASH latency can be modified through this function.
Parameters
UTILS_PLLInitStructpointer to a LL_UTILS_PLLInitTypeDef structure that contains the configuration information for the PLL.
UTILS_ClkInitStructpointer to a LL_UTILS_ClkInitTypeDef structure that contains the configuration information for the BUS prescalers.
Return values
AnErrorStatus enumeration value:
  • SUCCESS: Max frequency configuration done
  • ERROR: Max frequency configuration not done

Definition at line 334 of file stm32f1xx_ll_utils.c.

336 {
337  ErrorStatus status = SUCCESS;
338  uint32_t pllfreq = 0U;
339 
340  /* Check if one of the PLL is enabled */
341  if (UTILS_PLL_IsBusy() == SUCCESS)
342  {
343 #if defined(RCC_PLLSRC_PREDIV1_SUPPORT)
344  /* Check PREDIV value */
345  assert_param(IS_LL_UTILS_PREDIV_VALUE(UTILS_PLLInitStruct->PLLDiv));
346 #else
347  /* Force PREDIV value to 2 */
348  UTILS_PLLInitStruct->Prediv = LL_RCC_PREDIV_DIV_2;
349 #endif /*RCC_PLLSRC_PREDIV1_SUPPORT*/
350  /* Calculate the new PLL output frequency */
351  pllfreq = UTILS_GetPLLOutputFrequency(HSI_VALUE, UTILS_PLLInitStruct);
352 
353  /* Enable HSI if not enabled */
354  if (LL_RCC_HSI_IsReady() != 1U)
355  {
356  LL_RCC_HSI_Enable();
357  while (LL_RCC_HSI_IsReady() != 1U)
358  {
359  /* Wait for HSI ready */
360  }
361  }
362 
363  /* Configure PLL */
364  LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI_DIV_2, UTILS_PLLInitStruct->PLLMul);
365 
366  /* Enable PLL and switch system clock to PLL */
367  status = UTILS_EnablePLLAndSwitchSystem(pllfreq, UTILS_ClkInitStruct);
368  }
369  else
370  {
371  /* Current PLL configuration cannot be modified */
372  status = ERROR;
373  }
374 
375  return status;
376 }

◆ 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
HCLKFrequencyHCLK frequency in Hz (can be calculated thanks to RCC helper macro)
Return values
None

Definition at line 240 of file stm32f1xx_ll_utils.c.

241 {
242  /* HCLK clock frequency */
243  SystemCoreClock = HCLKFrequency;
244 }
ERROR
@ ERROR
Definition: stm32f1xx.h:167
IS_LL_UTILS_PREDIV_VALUE
#define IS_LL_UTILS_PREDIV_VALUE(__VALUE__)
Definition: stm32f1xx_ll_utils.c:124
IS_LL_UTILS_HSE_FREQUENCY
#define IS_LL_UTILS_HSE_FREQUENCY(__FREQUENCY__)
Definition: stm32f1xx_ll_utils.c:133
UTILS_PLL_IsBusy
static ErrorStatus UTILS_PLL_IsBusy(void)
Function to check that PLL can be modified.
Definition: stm32f1xx_ll_utils.c:495
LL_UTILS_PLLInitTypeDef::Prediv
uint32_t Prediv
Definition: stm32f1xx_ll_utils.h:98
assert_param
#define assert_param(expr)
Definition: stm32f1xx_ll_utils.c:27
IS_LL_UTILS_HSE_BYPASS
#define IS_LL_UTILS_HSE_BYPASS(__STATE__)
Definition: stm32f1xx_ll_utils.c:130
UTILS_EnablePLLAndSwitchSystem
static ErrorStatus UTILS_EnablePLLAndSwitchSystem(uint32_t SYSCLK_Frequency, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct)
Function to enable PLL and switch system clock to PLL.
Definition: stm32f1xx_ll_utils.c:535
RCC_CFGR_PLLSRC
#define RCC_CFGR_PLLSRC
Definition: stm32f103xb.h:1017
HSI_VALUE
#define HSI_VALUE
Internal High Speed oscillator (HSI) value. This value is used by the RCC HAL module to compute the s...
Definition: stm32f1xx_hal_conf.h:99
UTILS_GetPLLOutputFrequency
static uint32_t UTILS_GetPLLOutputFrequency(uint32_t PLL_InputFrequency, LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct)
Function to check that PLL can be modified.
Definition: stm32f1xx_ll_utils.c:471
LL_UTILS_PLLInitTypeDef::PLLMul
uint32_t PLLMul
Definition: stm32f1xx_ll_utils.h:92
SystemCoreClock
uint32_t SystemCoreClock
Definition: system_stm32f1xx.c:142
SUCCESS
@ SUCCESS
Definition: stm32f1xx.h:166
LL_UTILS_HSEBYPASS_ON
#define LL_UTILS_HSEBYPASS_ON
Definition: stm32f1xx_ll_utils.h:143
ErrorStatus
ErrorStatus
Definition: stm32f1xx.h:164