CMU - Clock Management Unit
Description
Clock management unit (CMU) Peripheral API.
This module contains functions for the CMU peripheral of Silicon Labs 32-bit MCUs and SoCs. The CMU module controls oscillators, clocks gates, clock multiplexers, pre-scalers, calibration modules and wait-states.
Data Structures |
|
struct | CMU_LFXOInit_TypeDef |
LFXO initialization structure.
|
|
struct | CMU_HFXOInit_TypeDef |
HFXO initialization structure.
|
|
struct | CMU_DPLLInit_TypeDef |
DPLL initialization structure.
|
|
Functions |
|
uint32_t | CMU_ClockFreqGet ( CMU_Clock_TypeDef clock) |
Get clock frequency for a clock point.
|
|
CMU_HFRCOEM23Freq_TypeDef | CMU_HFRCOEM23BandGet (void) |
Get HFRCOEM23 band in use.
|
|
void | CMU_HFRCOEM23BandSet ( CMU_HFRCOEM23Freq_TypeDef freq) |
Set HFRCOEM23 band and the tuning value based on the value in the calibration table made during production.
|
|
uint32_t | CMU_Calibrate (uint32_t cycles, CMU_Select_TypeDef ref) |
Calibrate an oscillator.
|
|
void | CMU_CalibrateConfig (uint32_t downCycles, CMU_Select_TypeDef downSel, CMU_Select_TypeDef upSel) |
Configure clock calibration.
|
|
uint32_t | CMU_CalibrateCountGet (void) |
Get calibration count value.
|
|
void | CMU_ClkOutPinConfig (uint32_t clkNo, CMU_Select_TypeDef sel, CMU_ClkDiv_TypeDef clkDiv, GPIO_Port_TypeDef port, unsigned int pin) |
Direct a clock to a GPIO pin.
|
|
CMU_ClkDiv_TypeDef | CMU_ClockDivGet ( CMU_Clock_TypeDef clock) |
Get clock divisor.
|
|
void | CMU_ClockDivSet ( CMU_Clock_TypeDef clock, CMU_ClkDiv_TypeDef div) |
Set clock divisor.
|
|
CMU_Select_TypeDef | CMU_ClockSelectGet ( CMU_Clock_TypeDef clock) |
Get currently selected reference clock used for a clock branch.
|
|
void | CMU_ClockSelectSet ( CMU_Clock_TypeDef clock, CMU_Select_TypeDef ref) |
Select reference clock/oscillator used for a clock branch.
|
|
uint16_t | CMU_LF_ClockPrecisionGet ( CMU_Clock_TypeDef clock) |
Gets the precision (in PPM) of the specified low frequency clock branch.
|
|
bool | CMU_DPLLLock (const CMU_DPLLInit_TypeDef *init) |
Lock the DPLL to a given frequency.
|
|
CMU_HFRCODPLLFreq_TypeDef | CMU_HFRCODPLLBandGet (void) |
Get HFRCODPLL band in use.
|
|
void | CMU_HFRCODPLLBandSet ( CMU_HFRCODPLLFreq_TypeDef freq) |
Set HFRCODPLL band and the tuning value based on the value in the calibration table made during production.
|
|
void | CMU_HFXOInit (const CMU_HFXOInit_TypeDef *hfxoInit) |
Initialize all HFXO control registers.
|
|
void | CMU_LFXOInit (const CMU_LFXOInit_TypeDef *lfxoInit) |
Initialize LFXO control registers.
|
|
void | CMU_LFXOPrecisionSet (uint16_t precision) |
Sets LFXO's crystal precision, in PPM.
|
|
uint32_t | CMU_OscillatorTuningGet ( CMU_Osc_TypeDef osc) |
Get oscillator frequency tuning setting.
|
|
void | CMU_OscillatorTuningSet ( CMU_Osc_TypeDef osc, uint32_t val) |
Set the oscillator frequency tuning control.
|
|
void | CMU_UpdateWaitStates (uint32_t freq, int vscale) |
Configure wait state settings necessary to switch to a given core clock frequency at a certain voltage scale level.
|
|
void | CMU_ClockEnable ( CMU_Clock_TypeDef clock, bool enable) |
Enable/disable a clock.
|
|
void | CMU_CalibrateCont (bool enable) |
Configures continuous calibration mode.
|
|
void | CMU_CalibrateStart (void) |
Starts calibration.
|
|
void | CMU_CalibrateStop (void) |
Stop calibration counters.
|
|
void | CMU_DPLLUnlock (void) |
Unlock the DPLL.
|
|
void | CMU_IntClear (uint32_t flags) |
Clear one or more pending CMU interrupt flags.
|
|
void | CMU_IntDisable (uint32_t flags) |
Disable one or more CMU interrupt sources.
|
|
void | CMU_IntEnable (uint32_t flags) |
Enable one or more CMU interrupt sources.
|
|
uint32_t | CMU_IntGet (void) |
Get pending CMU interrupt sources.
|
|
uint32_t | CMU_IntGetEnabled (void) |
Get enabled and pending CMU interrupt flags.
|
|
void | CMU_IntSet (uint32_t flags) |
Set one or more pending CMU interrupt sources.
|
|
void | CMU_Lock (void) |
Lock CMU register access in order to protect registers contents against unintended modification.
|
|
void | CMU_OscillatorEnable ( CMU_Osc_TypeDef osc, bool enable, bool wait) |
Enable/disable oscillator.
|
|
void | CMU_Unlock (void) |
Unlock CMU register access so that writing to registers is possible.
|
|
void | CMU_WdogLock (void) |
Lock WDOG register access in order to protect registers contents against unintended modification.
|
|
void | CMU_WdogUnlock (void) |
Unlock WDOG register access so that writing to registers is possible.
|
|
uint32_t | CMU_PrescToLog2 (uint32_t presc) |
Convert prescaler dividend to a logarithmic value.
|
|
Macros |
|
#define | CMU_HFRCODPLL_MIN cmuHFRCODPLLFreq_1M0Hz |
HFRCODPLL maximum frequency.
|
|
#define | CMU_HFRCODPLL_MAX cmuHFRCODPLLFreq_80M0Hz |
HFRCODPLL minimum frequency.
|
|
#define | CMU_HFRCOEM23_MIN cmuHFRCOEM23Freq_1M0Hz |
HFRCOEM23 maximum frequency.
|
|
#define | CMU_HFRCOEM23_MAX cmuHFRCOEM23Freq_40M0Hz |
HFRCOEM23 minimum frequency.
|
|
#define | CMU_LFXOINIT_DEFAULT |
Default LFXO initialization values for XTAL mode.
|
|
#define | CMU_LFXOINIT_EXTERNAL_CLOCK |
Default LFXO initialization values for external clock mode.
|
|
#define | CMU_LFXOINIT_EXTERNAL_SINE |
Default LFXO initialization values for external sine mode.
|
|
#define | CMU_HFXOINIT_DEFAULT |
Default HFXO initialization values for XTAL mode.
|
|
#define | CMU_HFXOINIT_EXTERNAL_SINE |
Default HFXO initialization values for external sine mode.
|
|
#define | CMU_DPLL_LFXO_TO_40MHZ |
DPLL initialization values for 39,998,805 Hz using LFXO as reference clock, M=2 and N=3661.
|
|
#define | CMU_DPLL_HFXO_TO_76_8MHZ |
DPLL initialization values for 76,800,000 Hz using HFXO as reference clock, M = 1919, N = 3839.
|
|
#define | CMU_DPLL_HFXO_TO_80MHZ |
DPLL initialization values for 80,000,000 Hz using HFXO as reference clock, M = 1919, N = 3999.
|
|
#define | CMU_DPLLINIT_DEFAULT |
Default configurations for DPLL initialization.
|
|
Typedefs |
|
typedef uint32_t | CMU_ClkDiv_TypeDef |
Clock divider configuration.
|
|
Function Documentation
◆ CMU_ClockFreqGet()
uint32_t CMU_ClockFreqGet | ( | CMU_Clock_TypeDef |
clock
|
) |
Get clock frequency for a clock point.
- Parameters
-
[in] clock
Clock point to fetch frequency for.
- Returns
- The current frequency in Hz.
◆ CMU_HFRCOEM23BandGet()
CMU_HFRCOEM23Freq_TypeDef CMU_HFRCOEM23BandGet | ( | void |
|
) |
Get HFRCOEM23 band in use.
- Returns
- HFRCOEM23 band in use.
◆ CMU_HFRCOEM23BandSet()
void CMU_HFRCOEM23BandSet | ( | CMU_HFRCOEM23Freq_TypeDef |
freq
|
) |
Set HFRCOEM23 band and the tuning value based on the value in the calibration table made during production.
- Parameters
-
[in] freq
HFRCOEM23 frequency band to activate.
◆ CMU_Calibrate()
uint32_t CMU_Calibrate | ( | uint32_t |
cycles,
|
CMU_Select_TypeDef |
ref
|
||
) |
Calibrate an oscillator.
Run a calibration of a selectable reference clock againt HCLK. Please refer to the reference manual, CMU chapter, for further details.
- Note
- This function will not return until calibration measurement is completed.
- Parameters
-
[in] cycles
The number of HCLK cycles to run calibration. Increasing this number increases precision, but the calibration will take more time. [in] ref
The reference clock used to compare against HCLK.
- Returns
- The number of ticks the selected reference clock ticked while running cycles ticks of the HCLK clock.
◆ CMU_CalibrateConfig()
void CMU_CalibrateConfig | ( | uint32_t |
downCycles,
|
CMU_Select_TypeDef |
downSel,
|
||
CMU_Select_TypeDef |
upSel
|
||
) |
Configure clock calibration.
Configure a calibration for a selectable clock source against another selectable reference clock. Refer to the reference manual, CMU chapter, for further details.
- Note
- After configuration, a call to CMU_CalibrateStart() is required, and the resulting calibration value can be read with the CMU_CalibrateCountGet() function call.
- Parameters
-
[in] downCycles
The number of downSel clock cycles to run calibration. Increasing this number increases precision, but the calibration will take more time. [in] downSel
The clock which will be counted down downCycles cycles. [in] upSel
The reference clock, the number of cycles generated by this clock will be counted and added up, the result can be given with the CMU_CalibrateCountGet() function call.
◆ CMU_CalibrateCountGet()
uint32_t CMU_CalibrateCountGet | ( | void |
|
) |
Get calibration count value.
- Note
- If continuous calibrartion mode is active, calibration busy will almost always be off, and we just need to read the value, where the normal case would be that this function call has been triggered by the CALRDY interrupt flag.
- Returns
- Calibration count, the number of UPSEL clocks (see CMU_CalibrateConfig() ) in the period of DOWNSEL oscillator clock cycles configured by a previous write operation to CMU->CALCNT.
◆ CMU_ClkOutPinConfig()
void CMU_ClkOutPinConfig | ( | uint32_t |
clkNo,
|
CMU_Select_TypeDef |
sel,
|
||
CMU_ClkDiv_TypeDef |
clkDiv,
|
||
GPIO_Port_TypeDef |
port,
|
||
unsigned int |
pin
|
||
) |
Direct a clock to a GPIO pin.
- Parameters
-
[in] clkNo
Selects between CLKOUT0, CLKOUT1 or CLKOUT2 outputs. Use values 0,1or 2. [in] sel
Select clock source. [in] clkDiv
Select a clock divisor (1..32). Only applicable when cmuSelect_EXPCLK is slexted as clock source. [in] port
GPIO port. [in] pin
GPIO pin.
- Note
- Refer to the reference manual and the datasheet for details on which GPIO port/pins that are available.
◆ CMU_ClockDivGet()
CMU_ClkDiv_TypeDef CMU_ClockDivGet | ( | CMU_Clock_TypeDef |
clock
|
) |
Get clock divisor.
- Parameters
-
[in] clock
Clock point to get divisor for. Notice that not all clock points have a divisors. Please refer to CMU overview in reference manual.
- Returns
-
The current clock point divisor. 1 is returned if
clock
specifies a clock point without divisor.
◆ CMU_ClockDivSet()
void CMU_ClockDivSet | ( | CMU_Clock_TypeDef |
clock,
|
CMU_ClkDiv_TypeDef |
div
|
||
) |
Set clock divisor.
- Parameters
-
[in] clock
Clock point to set divisor for. Notice that not all clock points have a divisor, please refer to CMU overview in the reference manual. [in] div
The clock divisor to use.
◆ CMU_ClockSelectGet()
CMU_Select_TypeDef CMU_ClockSelectGet | ( | CMU_Clock_TypeDef |
clock
|
) |
Get currently selected reference clock used for a clock branch.
- Parameters
-
[in] clock
Clock branch to fetch selected ref. clock for.
- Returns
-
Reference clock used for clocking selected branch,
cmuSelect_Error
if invalid
clock
provided.
◆ CMU_ClockSelectSet()
void CMU_ClockSelectSet | ( | CMU_Clock_TypeDef |
clock,
|
CMU_Select_TypeDef |
ref
|
||
) |
Select reference clock/oscillator used for a clock branch.
- Parameters
-
[in] clock
Clock branch to select reference clock for. [in] ref
Reference selected for clocking, please refer to reference manual for for details on which reference is available for a specific clock branch.
◆ CMU_LF_ClockPrecisionGet()
uint16_t CMU_LF_ClockPrecisionGet | ( | CMU_Clock_TypeDef |
clock
|
) |
Gets the precision (in PPM) of the specified low frequency clock branch.
- Parameters
-
[in] clock
Clock branch.
- Returns
- Precision, in PPM, of the specified clock branch.
- Note
- This function is only for internal usage.
- The current implementation of this function is used to determine if the clock has a precision <= 500 ppm or not (which is the minimum required for BLE). Future version of this function should provide more accurate precision numbers to allow for further optimizations from the stacks.
◆ CMU_DPLLLock()
bool CMU_DPLLLock | ( | const CMU_DPLLInit_TypeDef * |
init
|
) |
Lock the DPLL to a given frequency.
The frequency is given by: Fout = Fref * (N+1) / (M+1).
- Note
-
This function does not check if the given N & M values will actually produce the desired target frequency.
N & M limitations:
300 < N <= 4095
0 <= M <= 4095
Any peripheral running off HFRCODPLL should be switched to a lower frequency clock (if possible) prior to calling this function to avoid over-clocking.
- Parameters
-
[in] init
DPLL setup parameter struct.
- Returns
- Returns false on invalid target frequency or DPLL locking error.
◆ CMU_HFRCODPLLBandGet()
CMU_HFRCODPLLFreq_TypeDef CMU_HFRCODPLLBandGet | ( | void |
|
) |
Get HFRCODPLL band in use.
- Returns
- HFRCODPLL band in use.
◆ CMU_HFRCODPLLBandSet()
void CMU_HFRCODPLLBandSet | ( | CMU_HFRCODPLLFreq_TypeDef |
freq
|
) |
Set HFRCODPLL band and the tuning value based on the value in the calibration table made during production.
- Parameters
-
[in] freq
HFRCODPLL frequency band to activate.
◆ CMU_HFXOInit()
void CMU_HFXOInit | ( | const CMU_HFXOInit_TypeDef * |
hfxoInit
|
) |
Initialize all HFXO control registers.
- Note
- HFXO configuration should be obtained from a configuration tool, app note or xtal datasheet. This function returns early if HFXO is already selected as SYSCLK.
- Parameters
-
[in] hfxoInit
HFXO setup parameters.
◆ CMU_LFXOInit()
void CMU_LFXOInit | ( | const CMU_LFXOInit_TypeDef * |
lfxoInit
|
) |
Initialize LFXO control registers.
- Note
- LFXO configuration should be obtained from a configuration tool, app note or xtal datasheet. This function disables the LFXO to ensure a valid state before update.
- Parameters
-
[in] lfxoInit
LFXO setup parameters
◆ CMU_LFXOPrecisionSet()
void CMU_LFXOPrecisionSet | ( | uint16_t |
precision
|
) |
Sets LFXO's crystal precision, in PPM.
- Note
- LFXO precision should be obtained from a xtal datasheet.
- Parameters
-
[in] precision
LFXO's crystal precision, in PPM.
◆ CMU_OscillatorTuningGet()
uint32_t CMU_OscillatorTuningGet | ( | CMU_Osc_TypeDef |
osc
|
) |
Get oscillator frequency tuning setting.
- Parameters
-
[in] osc
Oscillator to get tuning value for.
- Returns
- The oscillator frequency tuning setting in use.
◆ CMU_OscillatorTuningSet()
void CMU_OscillatorTuningSet | ( | CMU_Osc_TypeDef |
osc,
|
uint32_t |
val
|
||
) |
Set the oscillator frequency tuning control.
- Note
- Oscillator tuning is done during production, and the tuning value is automatically loaded after a reset. Changing the tuning value from the calibrated value is for more advanced use. Certain oscillators also have build-in tuning optimization.
- Parameters
-
[in] osc
Oscillator to set tuning value for. [in] val
The oscillator frequency tuning setting to use.
◆ CMU_UpdateWaitStates()
void CMU_UpdateWaitStates | ( | uint32_t |
freq,
|
int |
vscale
|
||
) |
Configure wait state settings necessary to switch to a given core clock frequency at a certain voltage scale level.
This function will set up the necessary flash wait states. Updating the wait state configuration must be done before increasing the clock frequency and it must be done after decreasing the clock frequency. Updating the wait state configuration must be done before core voltage is decreased and it must be done after a core voltage is increased.
- Parameters
-
[in] freq
The core clock frequency to configure wait-states. [in] vscale
The voltage scale to configure wait-states. Expected values are 0 or 1, higher number is lower voltage. - 0 = 1.1 V (VSCALE2)
- 1 = 1.0 V (VSCALE1)
◆ CMU_ClockEnable()
|
inline |
Enable/disable a clock.
- Note
- This is a dummy function to solve backward compatibility issues.
- Parameters
-
[in] clock
The clock to enable/disable. [in] enable
- true - enable specified clock.
- false - disable specified clock.
◆ CMU_CalibrateCont()
|
inline |
Configures continuous calibration mode.
- Parameters
-
[in] enable
If true, enables continuous calibration, if false disables continuous calibration.