STM8L15x Standard Peripherals Drivers
|
System clock configuration functions. More...
Functions | |
uint32_t | CLK_GetClockFreq (void) |
Returns the frequencies of different the SYSCLK. | |
CLK_SYSCLKSource_TypeDef | CLK_GetSYSCLKSource (void) |
Returns the clock source used as system clock. | |
void | CLK_SYSCLKDivConfig (CLK_SYSCLKDiv_TypeDef CLK_SYSCLKDiv) |
Configures the System clock (SYSCLK) dividers. | |
void | CLK_SYSCLKSourceConfig (CLK_SYSCLKSource_TypeDef CLK_SYSCLKSource) |
Configures the system clock (SYSCLK). | |
void | CLK_SYSCLKSourceSwitchCmd (FunctionalState NewState) |
Enables or disables the clock switch execution. |
Detailed Description
System clock configuration functions.
=============================================================================== System clock configuration functions =============================================================================== This section provides functions allowing to configure the System clock. 1. Several clock sources can be used to drive the System clock (SYSCLK): HSI, HSE, LSI and LSE. You can use "CLK_GetClocksFreq()" function to retrieve the frequencies of these clocks. @note All the peripheral clocks are derived from the System clock (SYSCLK) except: - BEEP: the Beeper clock can be derived either from a LSE or LSI clock sources. You have to use CLK_BEEPClockConfig() function to configure this clock. - RTC: the RTC clock can be derived either from the LSI, LSE, HSI or HSE clock divided by 1 to 64. You have to use CLK_RTCClockConfig() functions to configure this clock. - LCD : LCD clock is the RTC Clock divided by 2. - IWDG clock which is always the LSI clock. 2. The maximum frequency of the SYSCLK is 16 MHz.
Function Documentation
uint32_t CLK_GetClockFreq | ( | void | ) |
Returns the frequencies of different the SYSCLK.
- Note:
- 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 HSI, function returns values based on HSI_VALUE(*)
- If SYSCLK source is HSE, function returns values based on HSE_VALUE(**)
- If SYSCLK source is LSE, function returns values based on LSE_VALUE(***)
- If SYSCLK source is LSI, function returns values based on LSI_VALUE(****)
- (*) HSI_VALUE is a constant defined in stm8l15x.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 stm8l15x.h file (default value 16 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.
- (***) LSI_VALUE is a constant defined in stm8l15x.h file (default value 38 KHz) but the real value may vary depending on the variations in voltage and temperature.
- (****) LSE_VALUE is a constant defined in stm8l15x.h file (default value 32,768 KHz), user has to ensure that LSE_VALUE is same as the real frequency of the crystal used. Otherwise, this function may have wrong result.
- The result of this function could be not correct when using fractional value for HSE crystal.
- Note:
- This function can be used by the user application to compute the baudrate for the communication peripherals or configure other parameters.
- Each time SYSCLK clock changes, this function must be called to update the returned value. Otherwise, any configuration based on this function will be incorrect.
Definition at line 472 of file stm8l15x_clk.c.
References CLK, CLK_CKDIVR_CKM, CLK_SYSCLKSource_HSE, CLK_SYSCLKSource_HSI, CLK_SYSCLKSource_LSI, HSE_VALUE, HSI_VALUE, LSE_VALUE, LSI_VALUE, and SYSDivFactor.
Referenced by I2C_Init(), and USART_Init().
CLK_SYSCLKSource_TypeDef CLK_GetSYSCLKSource | ( | void | ) |
Returns the clock source used as system clock.
Definition at line 429 of file stm8l15x_clk.c.
References CLK.
void CLK_SYSCLKDivConfig | ( | CLK_SYSCLKDiv_TypeDef | CLK_SYSCLKDiv | ) |
Configures the System clock (SYSCLK) dividers.
Definition at line 522 of file stm8l15x_clk.c.
References CLK, and IS_CLK_SYSTEM_DIVIDER.
void CLK_SYSCLKSourceConfig | ( | CLK_SYSCLKSource_TypeDef | CLK_SYSCLKSource | ) |
Configures the system clock (SYSCLK).
- Note:
- The HSI is used (enabled by hardware) as system clock source after startup from Reset, wake-up from Halt and active Halt modes, or in case of failure of the HSE used as system clock (if the Clock Security System CSS is enabled).
- A switch from one clock source to another occurs only if the target clock source is ready (clock stable after startup delay or PLL locked). You can use CLK_GetSYSCLKSource() function to know which clock is currently used as system clock source.
Definition at line 410 of file stm8l15x_clk.c.
References CLK, and IS_CLK_SOURCE.
void CLK_SYSCLKSourceSwitchCmd | ( | FunctionalState | NewState | ) |
Enables or disables the clock switch execution.
Definition at line 535 of file stm8l15x_clk.c.
References CLK, CLK_SWCR_SWEN, DISABLE, and IS_FUNCTIONAL_STATE.