STM8L15x Standard Peripherals Drivers: Internal and external clocks, CSS and CCO configuration functions

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

Internal and external clocks, CSS and CCO configuration functions

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.
Parameters:
CLK_HSICalibrationValue: calibration trimming value. This parameter must be a number between [(HSICALR regiter value) -12] and [(HSICALR regiter value) + 8 ]
Note:
Once HSITRIMR register configured, its value is used instead of the HSICALR register values.
Return values:
None

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.
Parameters:
CLK_CCOSource,:specifies the clock source to output. This parameter can be one of the following values:
  • CLK_CCOSource_Off: No clock selected as CCO source
  • CLK_CCOSource_HSI: HSI clock selected as CCO source
  • CLK_CCOSource_LSI: LSI clock selected as CCO source
  • CLK_CCOSource_LSE: LSE clock selected as CCO source
  • CLK_CCOSource_HSE: HSE clock selected as CCO source
CLK_CCODiv,:specifies the CCO prescaler. This parameter can be one of the following values:
  • CLK_CCODiv_1: no division applied to CCO clock
  • CLK_CCODiv_2: division by 2 applied to CCO clock
  • CLK_CCODiv_4: division by 4 applied to CCO clock
  • CLK_CCODiv_8: division by 8 applied to CCO clock
  • CLK_CCODiv_16: division by 16 applied to CCO clock
  • CLK_CCODiv_32: division by 32 applied to CCO clock
  • CLK_CCODiv_64: division by 64 applied to CCO clock
Return values:
None

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.
Parameters:
None
Return values:
None

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.

Parameters:
None
Return values:
None

Definition at line 311 of file stm8l15x_clk.c.

References CLK, CLK_CSSR_CSSDGON, DISABLE, and IS_FUNCTIONAL_STATE.

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.
Parameters:
CLK_HSE,:specifies the new state of the HSE. This parameter can be one of the following values:
  • CLK_HSE_OFF: turn OFF the HSE oscillator, HSERDY flag goes low after 6 HSE oscillator clock cycles.
  • CLK_HSE_ON: turn ON the HSE oscillator
  • CLK_HSE_Bypass: HSE oscillator bypassed with external clock
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.
Return values:
None

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.
Parameters:
NewState,:new state of the HSI. This parameter can be: ENABLE or DISABLE.
Note:
When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator clock cycles.
Return values:
None

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.
Parameters:
CLK_LSE,:specifies the new state of the LSE. This parameter can be one of the following values:
  • CLK_LSE_OFF: turn OFF the LSE oscillator, LSERDY flag goes low after 6 LSE oscillator clock cycles.
  • CLK_LSE_ON: turn ON the LSE oscillator
  • CLK_LSE_Bypass: LSE oscillator bypassed with external clock
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.
Return values:
None

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.
Parameters:
NewState,:new state of the LSI. This parameter can be: ENABLE or DISABLE.
Note:
When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator clock cycles.
Return values:
None

Definition at line 206 of file stm8l15x_clk.c.

References CLK, CLK_ICKCR_LSION, DISABLE, and IS_FUNCTIONAL_STATE.

STM8S Firmware Library: Overview

 

 

 

For complete documentation on STM8L15x 8-bit microcontrollers platform visit www.st.com