STM32L443xx HAL User Manual
|
Initialization and Configuration functions. More...
Functions | |
HAL_StatusTypeDef | HAL_RCC_DeInit (void) |
Reset the RCC clock configuration to the default reset state. | |
HAL_StatusTypeDef | HAL_RCC_OscConfig (RCC_OscInitTypeDef *RCC_OscInitStruct) |
Initialize the RCC Oscillators according to the specified parameters in the RCC_OscInitTypeDef. | |
HAL_StatusTypeDef | HAL_RCC_ClockConfig (RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency) |
Initialize the CPU, AHB and APB busses clocks according to the specified parameters in the RCC_ClkInitStruct. |
Initialization and Configuration functions.
=============================================================================== ##### Initialization and de-initialization functions ##### =============================================================================== [..] This section provides functions allowing to configure the internal and external oscillators (HSE, HSI, LSE, MSI, LSI, PLL, CSS and MCO) and the System busses clocks (SYSCLK, AHB, APB1 and APB2). [..] Internal/external clock and PLL configuration (+) HSI (high-speed internal): 16 MHz factory-trimmed RC used directly or through the PLL as System clock source. (+) MSI (Mutiple Speed Internal): Its frequency is software trimmable from 100KHZ to 48MHZ. It can be used to generate the clock for the USB OTG FS (48 MHz). The number of flash wait states is automatically adjusted when MSI range is updated with HAL_RCC_OscConfig() and the MSI is used as System clock source. (+) LSI (low-speed internal): 32 KHz low consumption RC used as IWDG and/or RTC clock source. (+) HSE (high-speed external): 4 to 48 MHz crystal oscillator used directly or through the PLL as System clock source. Can be used also optionally as RTC clock source. (+) LSE (low-speed external): 32.768 KHz oscillator used optionally as RTC clock source. (+) PLL (clocked by HSI, HSE or MSI) providing up to three independent output clocks: (++) The first output is used to generate the high speed system clock (up to 80MHz). (++) The second output is used to generate the clock for the USB OTG FS (48 MHz), the random analog generator (<=48 MHz) and the SDMMC1 (<= 48 MHz). (++) The third output is used to generate an accurate clock to achieve high-quality audio performance on SAI interface. (+) PLLSAI1 (clocked by HSI, HSE or MSI) providing up to three independent output clocks: (++) The first output is used to generate SAR ADC1 clock. (++) The second output is used to generate the clock for the USB OTG FS (48 MHz), the random analog generator (<=48 MHz) and the SDMMC1 (<= 48 MHz). (++) The third output is used to generate an accurate clock to achieve high-quality audio performance on SAI interface. (+) PLLSAI2 (clocked by HSI, HSE or MSI) providing up to three independent output clocks: (++) The first output is used to generate an accurate clock to achieve high-quality audio performance on SAI interface. (++) The second output is used to generate either SAR ADC2 clock if ADC2 is present or LCD clock if LTDC is present. (++) The third output is used to generate DSI clock if DSI is present. (+) CSS (Clock security system): once enabled, if a HSE clock failure occurs (HSE used directly or through PLL as System clock source), the System clock is automatically switched to HSI and an interrupt is generated if enabled. The interrupt is linked to the Cortex-M4 NMI (Non-Maskable Interrupt) exception vector. (+) MCO (microcontroller clock output): used to output MSI, LSI, HSI, LSE, HSE or main PLL clock (through a configurable prescaler) on PA8 pin. [..] System, AHB and APB busses clocks configuration (+) Several clock sources can be used to drive the System clock (SYSCLK): MSI, HSI, HSE and main PLL. The AHB clock (HCLK) is derived from System clock through configurable prescaler and used to clock the CPU, memory and peripherals mapped on AHB bus (DMA, GPIO...). APB1 (PCLK1) and APB2 (PCLK2) clocks are derived from AHB clock through configurable prescalers and used to clock the peripherals mapped on these busses. You can use "HAL_RCC_GetSysClockFreq()" function to retrieve the frequencies of these clocks. -@- All the peripheral clocks are derived from the System clock (SYSCLK) except: (+@) SAI: the SAI clock can be derived either from a specific PLL (PLLSAI1) or (PLLSAI2) or from an external clock mapped on the SAI_CKIN pin. You have to use HAL_RCCEx_PeriphCLKConfig() function to configure this clock. (+@) RTC: the RTC clock can be derived either from the LSI, LSE or HSE clock divided by 2 to 31. You have to use __HAL_RCC_RTC_ENABLE() and HAL_RCCEx_PeriphCLKConfig() function to configure this clock. (+@) USB OTG FS, SDMMC1 and RNG: USB OTG FS requires a frequency equal to 48 MHz to work correctly, while the SDMMC1 and RNG peripherals require a frequency equal or lower than to 48 MHz. This clock is derived of the main PLL or PLLSAI1 through PLLQ divider. You have to enable the peripheral clock and use HAL_RCCEx_PeriphCLKConfig() function to configure this clock. (+@) IWDG clock which is always the LSI clock. (+) The maximum frequency of the SYSCLK, HCLK, PCLK1 and PCLK2 is 80 MHz. The clock source frequency should be adapted depending on the device voltage range as listed in the Reference Manual "Clock source frequency versus voltage scaling" chapter.
Table 1. HCLK clock frequency for other STM32L4 devices +-------------------------------------------------------+ | Latency | HCLK clock frequency (MHz) | | |-------------------------------------| | | voltage range 1 | voltage range 2 | | | 1.2 V | 1.0 V | |-----------------|------------------|------------------| |0WS(1 CPU cycles)| 0 < HCLK <= 16 | 0 < HCLK <= 6 | |-----------------|------------------|------------------| |1WS(2 CPU cycles)| 16 < HCLK <= 32 | 6 < HCLK <= 12 | |-----------------|------------------|------------------| |2WS(3 CPU cycles)| 32 < HCLK <= 48 | 12 < HCLK <= 18 | |-----------------|------------------|------------------| |3WS(4 CPU cycles)| 48 < HCLK <= 64 | 18 < HCLK <= 26 | |-----------------|------------------|------------------| |4WS(5 CPU cycles)| 64 < HCLK <= 80 | 18 < HCLK <= 26 | +-------------------------------------------------------+
Table 2. HCLK clock frequency for STM32L4+ devices +--------------------------------------------------------+ | Latency | HCLK clock frequency (MHz) | | |--------------------------------------| | | voltage range 1 | voltage range 2 | | | 1.2 V | 1.0 V | |-----------------|-------------------|------------------| |0WS(1 CPU cycles)| 0 < HCLK <= 20 | 0 < HCLK <= 8 | |-----------------|-------------------|------------------| |1WS(2 CPU cycles)| 20 < HCLK <= 40 | 8 < HCLK <= 16 | |-----------------|-------------------|------------------| |2WS(3 CPU cycles)| 40 < HCLK <= 60 | 16 < HCLK <= 26 | |-----------------|-------------------|------------------| |3WS(4 CPU cycles)| 60 < HCLK <= 80 | 16 < HCLK <= 26 | |-----------------|-------------------|------------------| |4WS(5 CPU cycles)| 80 < HCLK <= 100 | 16 < HCLK <= 26 | |-----------------|-------------------|------------------| |5WS(6 CPU cycles)| 100 < HCLK <= 120 | 16 < HCLK <= 26 | +--------------------------------------------------------+
HAL_StatusTypeDef HAL_RCC_ClockConfig | ( | RCC_ClkInitTypeDef * | RCC_ClkInitStruct, |
uint32_t | FLatency | ||
) |
Initialize the CPU, AHB and APB busses clocks according to the specified parameters in the RCC_ClkInitStruct.
RCC_ClkInitStruct | pointer to an RCC_OscInitTypeDef structure that contains the configuration information for the RCC peripheral. |
FLatency | FLASH Latency This parameter can be one of the following values:
|
None |
Definition at line 1110 of file stm32l4xx_hal_rcc.c.
References __HAL_FLASH_GET_LATENCY, __HAL_FLASH_SET_LATENCY, __HAL_RCC_GET_SYSCLK_SOURCE, RCC_ClkInitTypeDef::AHBCLKDivider, RCC_ClkInitTypeDef::APB1CLKDivider, RCC_ClkInitTypeDef::APB2CLKDivider, assert_param, CLOCKSWITCH_TIMEOUT_VALUE, RCC_ClkInitTypeDef::ClockType, HAL_GetTick(), HAL_InitTick(), HAL_RCC_GetSysClockFreq(), IS_FLASH_LATENCY, IS_RCC_CLOCKTYPE, IS_RCC_HCLK, IS_RCC_PCLK, IS_RCC_SYSCLKSOURCE, RCC_CLOCKTYPE_HCLK, RCC_CLOCKTYPE_PCLK1, RCC_CLOCKTYPE_PCLK2, RCC_CLOCKTYPE_SYSCLK, RCC_SYSCLK_DIV1, RCC_SYSCLK_DIV2, RCC_SYSCLKSOURCE_HSE, RCC_SYSCLKSOURCE_MSI, RCC_SYSCLKSOURCE_PLLCLK, RCC_ClkInitTypeDef::SYSCLKSource, and uwTickPrio.
HAL_StatusTypeDef HAL_RCC_DeInit | ( | void | ) |
Reset the RCC clock configuration to the default reset state.
HAL | status |
Definition at line 265 of file stm32l4xx_hal_rcc.c.
References CLOCKSWITCH_TIMEOUT_VALUE, HAL_GetTick(), HAL_InitTick(), MSI_TIMEOUT_VALUE, MSI_VALUE, PLL_TIMEOUT_VALUE, RCC_MSIRANGE_6, and uwTickPrio.
HAL_StatusTypeDef HAL_RCC_OscConfig | ( | RCC_OscInitTypeDef * | RCC_OscInitStruct | ) |
Initialize the RCC Oscillators according to the specified parameters in the RCC_OscInitTypeDef.
RCC_OscInitStruct | pointer to an RCC_OscInitTypeDef structure that contains the configuration information for the RCC Oscillators. |
HAL | status |
Definition at line 403 of file stm32l4xx_hal_rcc.c.
References __HAL_RCC_GET_MSI_RANGE, __HAL_RCC_GET_PLL_OSCSOURCE, __HAL_RCC_GET_SYSCLK_SOURCE, __HAL_RCC_HSE_CONFIG, __HAL_RCC_HSI48_DISABLE, __HAL_RCC_HSI48_ENABLE, __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST, __HAL_RCC_HSI_DISABLE, __HAL_RCC_HSI_ENABLE, __HAL_RCC_LSE_CONFIG, __HAL_RCC_LSI_DISABLE, __HAL_RCC_LSI_ENABLE, __HAL_RCC_MSI_CALIBRATIONVALUE_ADJUST, __HAL_RCC_MSI_DISABLE, __HAL_RCC_MSI_ENABLE, __HAL_RCC_MSI_RANGE_CONFIG, __HAL_RCC_PLL_CONFIG, __HAL_RCC_PLL_DISABLE, __HAL_RCC_PLL_ENABLE, __HAL_RCC_PLLCLKOUT_DISABLE, __HAL_RCC_PLLCLKOUT_ENABLE, __HAL_RCC_PWR_CLK_DISABLE, __HAL_RCC_PWR_CLK_ENABLE, assert_param, HAL_GetTick(), HAL_InitTick(), HAL_RCC_GetSysClockFreq(), HSE_TIMEOUT_VALUE, RCC_OscInitTypeDef::HSEState, HSI48_TIMEOUT_VALUE, RCC_OscInitTypeDef::HSI48State, HSI_TIMEOUT_VALUE, RCC_OscInitTypeDef::HSICalibrationValue, RCC_OscInitTypeDef::HSIState, IS_RCC_HSE, IS_RCC_HSI, IS_RCC_HSI48, IS_RCC_HSI_CALIBRATION_VALUE, IS_RCC_LSE, IS_RCC_LSI, IS_RCC_MSI, IS_RCC_MSI_CLOCK_RANGE, IS_RCC_MSICALIBRATION_VALUE, IS_RCC_OSCILLATORTYPE, IS_RCC_PLL, IS_RCC_PLLM_VALUE, IS_RCC_PLLN_VALUE, IS_RCC_PLLP_VALUE, IS_RCC_PLLQ_VALUE, IS_RCC_PLLR_VALUE, IS_RCC_PLLSOURCE, RCC_OscInitTypeDef::LSEState, LSI_TIMEOUT_VALUE, RCC_OscInitTypeDef::LSIState, MSI_TIMEOUT_VALUE, RCC_OscInitTypeDef::MSICalibrationValue, RCC_OscInitTypeDef::MSIClockRange, RCC_OscInitTypeDef::MSIState, RCC_OscInitTypeDef::OscillatorType, RCC_OscInitTypeDef::PLL, PLL_TIMEOUT_VALUE, RCC_PLLInitTypeDef::PLLM, RCC_PLLInitTypeDef::PLLN, RCC_PLLInitTypeDef::PLLP, RCC_PLLInitTypeDef::PLLQ, RCC_PLLInitTypeDef::PLLR, RCC_PLLInitTypeDef::PLLSource, RCC_PLLInitTypeDef::PLLState, RCC_DBP_TIMEOUT_VALUE, RCC_HSE_OFF, RCC_HSI48_OFF, RCC_HSI_OFF, RCC_LSE_OFF, RCC_LSE_TIMEOUT_VALUE, RCC_LSI_OFF, RCC_MSI_OFF, RCC_OSCILLATORTYPE_HSE, RCC_OSCILLATORTYPE_HSI, RCC_OSCILLATORTYPE_HSI48, RCC_OSCILLATORTYPE_LSE, RCC_OSCILLATORTYPE_LSI, RCC_OSCILLATORTYPE_MSI, RCC_PLL_48M1CLK, RCC_PLL_NONE, RCC_PLL_ON, RCC_PLL_SAI2CLK, RCC_PLL_SYSCLK, RCC_PLLP_DIV7, RCC_PLLSOURCE_HSE, RCC_PLLSOURCE_HSI, RCC_PLLSOURCE_MSI, RCC_PLLSOURCE_NONE, RCC_SetFlashLatencyFromMSIRange(), and uwTickPrio.