|
STM32G474xx HAL用户手册
|
初始化和配置函数。 更多...
函数 | |
| HAL_StatusTypeDef | HAL_RCC_DeInit (void) |
| 将RCC时钟配置复位到默认复位状态。 | |
| HAL_StatusTypeDef | HAL_RCC_OscConfig (const RCC_OscInitTypeDef *RCC_OscInitStruct) |
| 根据RCC_OscInitTypeDef中指定的参数初始化RCC振荡器。 | |
| HAL_StatusTypeDef | HAL_RCC_ClockConfig (const RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency) |
| 根据RCC_ClkInitStruct中指定的参数初始化CPU、AHB和APB总线时钟。 | |
初始化和配置函数。
===============================================================================
##### Initialization and de-initialization functions #####
===============================================================================
[..]
This section provides functions allowing to configure the internal and external oscillators
(HSE, HSI, LSE, LSI, PLL, CSS and MCO) and the System buses 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.
(+) 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) providing up to three independent output clocks:
(++) The first output is used to generate the high speed system clock (up to 170 MHz).
(++) The second output is used to generate the clock for the USB (48 MHz),
the QSPI (<= 48 MHz), the FDCAN, the SAI and the I2S.
(++) The third output is used to generate a clock for ADC
(+) 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 LSI, HSI, LSE, HSE,
main PLL clock, system clock or RC48 clock (through a configurable prescaler) on PA8 pin.
[..] System, AHB and APB buses clocks configuration
(+) Several clock sources can be used to drive the System clock (SYSCLK): 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 buses. 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:
(+@) 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 FS and RNG: USB FS requires a frequency equal to 48 MHz
to work correctly, while the RNG peripheral requires a frequency
equal or lower than to 48 MHz. This clock is derived of the main PLL
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 170 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.
表1. STM32G4xx器件HCLK时钟频率 +----------------------------------------------------------------------------+ | 等待周期 | HCLK时钟频率 (MHz) | | |----------------------------------------------------------| | | 电压范围1 | 电压范围1 | 电压范围2 | | | 升压模式 1.28 V | 正常模式 1.2 V | 1.0 V | |-----------------|-------------------|-------------------|------------------| |0WS(1 CPU周期)| HCLK <= 34 | HCLK <= 30 | HCLK <= 13 | |-----------------|-------------------|-------------------|------------------| |1WS(2 CPU周期)| HCLK <= 68 | HCLK <= 60 | HCLK <= 26 | |-----------------|-------------------|-------------------|------------------| |2WS(3 CPU周期)| HCLK <= 102 | HCLK <= 90 | - | |-----------------|-------------------|-------------------|------------------| |3WS(4 CPU周期)| HCLK <= 136 | HCLK <= 120 | - | |-----------------|-------------------|-------------------|------------------| |4WS(5 CPU周期)| HCLK <= 170 | HCLK <= 150 | - | +----------------------------------------------------------------------------+
| HAL_StatusTypeDef HAL_RCC_ClockConfig | ( | const RCC_ClkInitTypeDef * | RCC_ClkInitStruct, |
| uint32_t | FLatency | ||
| ) |
根据RCC_ClkInitStruct中指定的参数初始化CPU、AHB和APB总线时钟。
| RCC_ClkInitStruct | 指向RCC_OscInitTypeDef结构体的指针,该结构体包含RCC外设的配置信息。 |
| FLatency | FLASH等待周期。该参数可以是以下值之一:
|
| 无 |
定义位于文件stm32g4xx_hal_rcc.c的第766行。
引用了__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_GetSysClockFreqFromPLLSource()、RCC_HCLK_DIV16、RCC_SYSCLK_DIV1、RCC_SYSCLK_DIV2、RCC_SYSCLKSOURCE_HSE、RCC_SYSCLKSOURCE_PLLCLK、RCC_ClkInitTypeDef::SYSCLKSource和uwTickPrio。
| HAL_StatusTypeDef HAL_RCC_DeInit | ( | void | ) |
将RCC时钟配置复位到默认复位状态。
| HAL | 状态 |
定义位于文件stm32g4xx_hal_rcc.c的第219行。
引用了CLOCKSWITCH_TIMEOUT_VALUE、HAL_GetTick()、HAL_InitTick()、HSI_TIMEOUT_VALUE、HSI_VALUE、PLL_TIMEOUT_VALUE、RCC_HSICALIBRATION_DEFAULT和uwTickPrio。
| HAL_StatusTypeDef HAL_RCC_OscConfig | ( | const RCC_OscInitTypeDef * | RCC_OscInitStruct | ) |
根据RCC_OscInitTypeDef中指定的参数初始化RCC振荡器。
| RCC_OscInitStruct | 指向RCC_OscInitTypeDef结构体的指针,该结构体包含RCC振荡器的配置信息。 |
| HAL | 状态 |
定义位于文件stm32g4xx_hal_rcc.c的第312行。
引用了__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_PLL_CONFIG、__HAL_RCC_PLL_DISABLE、__HAL_RCC_PLL_ENABLE、__HAL_RCC_PLLCLKOUT_ENABLE、__HAL_RCC_PWR_CLK_DISABLE、__HAL_RCC_PWR_CLK_ENABLE、__HAL_RCC_PWR_IS_CLK_DISABLED、assert_param、HAL_GetTick()、HAL_InitTick()、HSE_TIMEOUT_VALUE、