STM8L15x Standard Peripherals Drivers
|
Internal and external clocks, CSS and CCO configuration functions. More...
Functions | |
void | CLK_AdjustHSICalibrationValue (uint8_t CLK_HSICalibrationValue) |
Adjusts the Internal High Speed oscillator (HSI) calibration value. | |
void | CLK_CCOConfig (CLK_CCOSource_TypeDef CLK_CCOSource, CLK_CCODiv_TypeDef CLK_CCODiv) |
Selects the clock source to output on CCO pin(PC4). | |
void | CLK_ClockSecuritySystemEnable (void) |
Enables the Clock Security System. | |
void | CLK_ClockSecuritySytemDeglitchCmd (FunctionalState NewState) |
Enables the Clock Security System deglitcher system. | |
void | CLK_DeInit (void) |
Deinitializes the CLK peripheral registers to their default reset values. | |
void | CLK_HSEConfig (CLK_HSE_TypeDef CLK_HSE) |
Configures the External High Speed oscillator (HSE). | |
void | CLK_HSICmd (FunctionalState NewState) |
Enables or disables the Internal High Speed oscillator (HSI). | |
void | CLK_LSEConfig (CLK_LSE_TypeDef CLK_LSE) |
Configures the External Low Speed oscillator (LSE). | |
void | CLK_LSICmd (FunctionalState NewState) |
Enables or disables the Internal Low Speed oscillator (LSI). |
Detailed Description
Internal and external clocks, CSS and CCO configuration functions.
=============================================================================== Internal/external clocks, CSS and CCO configuration functions =============================================================================== This section provides functions allowing to configure the internal/external clocks, CSS and CCO pins. 1. HSI (high-speed internal), 16 MHz factory-trimmed RC used directly as System clock source. 2. LSI (low-speed internal), 32 KHz low consumption RC used as IWDG and/or RTC and/or BEEP clock source. 3. HSE (high-speed external), 1 to 16 MHz crystal oscillator used directly as System clock source. Can be used also as RTC/LCD clock source. 4. LSE (low-speed external), 32 KHz oscillator used as RTC/LCD and/or BEEP clock source. 5. CSS (Clock security system), once enabled and if a HSE clock failure occurs (HSE used as System clock source), the System clock is automatically switched to HSI and an interrupt is generated if enabled. 6. CCO (configurable clock output), used to output HSI, LSE, HSE, HSI, LSI clock (through a configurable prescaler) on PC4 pin.
Function Documentation
void CLK_AdjustHSICalibrationValue | ( | uint8_t | CLK_HSICalibrationValue | ) |
Adjusts the Internal High Speed oscillator (HSI) calibration value.
- Note:
- The calibration is used to compensate for the variations in voltage and temperature that influence the frequency of the internal HSI RC.
- Note:
- Once HSITRIMR register configured, its value is used instead of the HSICALR register values.
Definition at line 182 of file stm8l15x_clk.c.
References CLK.
void CLK_CCOConfig | ( | CLK_CCOSource_TypeDef | CLK_CCOSource, |
CLK_CCODiv_TypeDef | CLK_CCODiv | ||
) |
Selects the clock source to output on CCO pin(PC4).
- Note:
- PC4 should be configured output push-pull with the speed that matches maximum output speed of the desired clock.
Definition at line 350 of file stm8l15x_clk.c.
References CLK, IS_CLK_OUTPUT, and IS_CLK_OUTPUT_DIVIDER.
void CLK_ClockSecuritySystemEnable | ( | void | ) |
Enables the Clock Security System.
- Note:
- If a failure is detected on the HSE oscillator clock, this oscillator is automatically disabled and an interrupt is generated to inform the software about the failure allowing the MCU to perform rescue operations.
- Once CSS is enabled it cannot be disabled until the next reset.
Definition at line 300 of file stm8l15x_clk.c.
References CLK, and CLK_CSSR_CSSEN.
void CLK_ClockSecuritySytemDeglitchCmd | ( | FunctionalState | NewState | ) |
Enables the Clock Security System deglitcher system.
Definition at line 311 of file stm8l15x_clk.c.
References CLK, CLK_CSSR_CSSDGON, DISABLE, and IS_FUNCTIONAL_STATE.
void CLK_DeInit | ( | void | ) |
Deinitializes the CLK peripheral registers to their default reset values.
Definition at line 114 of file stm8l15x_clk.c.
References CLK, CLK_CBEEPR_RESET_VALUE, CLK_CCOR_RESET_VALUE, CLK_CKDIVR_RESET_VALUE, CLK_CRTCR_RESET_VALUE, CLK_CSSR_RESET_VALUE, CLK_ECKCR_RESET_VALUE, CLK_HSICALR_RESET_VALUE, CLK_HSITRIMR_RESET_VALUE, CLK_HSIUNLCKR_RESET_VALUE, CLK_ICKCR_RESET_VALUE, CLK_PCKENR1_RESET_VALUE, CLK_PCKENR2_RESET_VALUE, CLK_PCKENR3_RESET_VALUE, CLK_REGCSR_RESET_VALUE, CLK_SWCR_RESET_VALUE, and CLK_SWR_RESET_VALUE.
void CLK_HSEConfig | ( | CLK_HSE_TypeDef | CLK_HSE | ) |
Configures the External High Speed oscillator (HSE).
- Note:
- After enabling the HSE (CLK_HSE_ON or CLK_HSE_Bypass), the application software should wait on HSERDY flag to be set indicating that HSE clock is stable and can be used to clock the system.
- HSE state can not be changed if it is used as system clock. In this case, you have to select another source of the system clock then change the HSE state (ex. disable it).
- The HSE is stopped by hardware when entering HALT and active HALT modes.
- Note:
- In case of Enabling HSE Bypass make sure that the HSE clock source is not used by the RTC, output or involved in a switching operation.
Definition at line 243 of file stm8l15x_clk.c.
References CLK, CLK_ECKCR_HSEBYP, CLK_ECKCR_HSEON, and IS_CLK_HSE.
void CLK_HSICmd | ( | FunctionalState | NewState | ) |
Enables or disables the Internal High Speed oscillator (HSI).
- Note:
- The HSI is stopped by hardware when entering Halt and active Halt modes. It is used (enabled by hardware) as system clock source after startup from Reset, wakeup from Halt and active Halt mode when the FHWU bit is set in the ICKCR register, or in case of HSE failure used as system clock (if the Clock Security System CSS is enabled).
- HSI can not be stopped if it is used as active CCO source, as active RTC clock, if the safe oscillator (AUX) is enabled or as system clock source, In this case, you have to select another source of the system clock then stop the HSI.
- After enabling the HSI, the application software should wait on HSIRDY flag to be set indicating that HSI clock is stable and can be used as system clock source.
- Note:
- When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator clock cycles.
Definition at line 154 of file stm8l15x_clk.c.
References CLK, CLK_ICKCR_HSION, DISABLE, and IS_FUNCTIONAL_STATE.
void CLK_LSEConfig | ( | CLK_LSE_TypeDef | CLK_LSE | ) |
Configures the External Low Speed oscillator (LSE).
- Note:
- After enabling the LSE (CLK_LSE_ON or CLK_LSE_Bypass), the application software should wait on LSERDY flag to be set indicating that LSE clock is stable and can be used to clock the RTC.
- Note:
- In case of Enabling LSE Bypass make sure that the LSE clock source is not used by the RTC, output or involved in a switching operation.
Definition at line 274 of file stm8l15x_clk.c.
References CLK, CLK_ECKCR_LSEBYP, CLK_ECKCR_LSEON, and IS_CLK_LSE.
void CLK_LSICmd | ( | FunctionalState | NewState | ) |
Enables or disables the Internal Low Speed oscillator (LSI).
- Note:
- After enabling the LSI, the application software should wait on LSIRDY flag to be set indicating that LSI clock is stable and can be used to clock the IWDG and/or the RTC.
- LSI can not be disabled if used as system clock source, as active CCO source, as BEEP clock source while BEEPAHALT bit is set or, as RTC active clock source.
- Note:
- When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator clock cycles.
Definition at line 206 of file stm8l15x_clk.c.
References CLK, CLK_ICKCR_LSION, DISABLE, and IS_FUNCTIONAL_STATE.