| Kinetis SDK v.2.0 API Reference Manual Rev. 0 Freescale Semiconductor, Inc.

- Main Page
- Related Pages
- API Reference

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
Multipurpose Clock Generator Lite (MCGLITE)
Clock Driver

## Overview

The KSDK provides a peripheral driver for the MCG_Lite module of Kinetis devices.

# Function description

The MCG_Lite driver provides three kinds of APIs:

1. APIs to get the MCG_Lite frequency.
2. APIs for MCG_Lite mode.
3. APIs for OSC setup.

## MCG_Lite clock frequency

The CLOCK_GetOutClkFreq(), CLOCK_GetInternalRefClkFreq() and CLOCK_GetPeriphClkFreq() functions are used to get the frequency of MCGOUTCLK, MCGIRCLK, and MCGPCLK based on the current hardware setting.

## MCG_Lite mode

The function CLOCK_GetMode() gets the current MCG_Lite mode.
The function CLOCK_SetMcgliteConfig() sets the MCG_Lite to a desired configuration. The MCG_Lite can't switch between the LIRC2M and LIRC8M. Instead, the function switches to the HIRC mode first and then switches to the target mode.

## OSC configuration

To enable the OSC clock, the MCG_Lite is needed together with the OSC module. The function CLOCK_InitOsc0() uses the MCG_Lite and the OSC to initialize the OSC. The OSC should be configured based on the board design.

## Data Structures
struct | sim_clock_config_t
| SIM configuration structure for clock setting. More...
struct | oscer_config_t
| OSC configuration for OSCERCLK. More...
struct | osc_config_t
| OSC Initialization Configuration Structure. More...
struct | mcglite_config_t
| MCG_Lite configure structure for mode change. More...

## Macros
#define | FSL_CLOCK_DRIVER_VERSION (MAKE_VERSION(2, 1, 0))
| Clock driver version. More...
#define | DMAMUX_CLOCKS
| Clock ip name array for DMAMUX. More...
#define | RTC_CLOCKS
| Clock ip name array for RTC. More...
#define | SAI_CLOCKS
| Clock ip name array for SAI. More...
#define | SPI_CLOCKS
| Clock ip name array for SPI. More...
#define | SLCD_CLOCKS
| Clock ip name array for SLCD. More...
#define | PIT_CLOCKS
| Clock ip name array for PIT. More...
#define | PORT_CLOCKS
| Clock ip name array for PORT. More...
#define | LPUART_CLOCKS
| Clock ip name array for LPUART. More...
#define | DAC_CLOCKS
| Clock ip name array for DAC. More...
#define | LPTMR_CLOCKS
| Clock ip name array for LPTMR. More...
#define | ADC16_CLOCKS
| Clock ip name array for ADC16. More...
#define | FLEXIO_CLOCKS
| Clock ip name array for FLEXIO. More...
#define | VREF_CLOCKS
| Clock ip name array for VREF. More...
#define | DMA_CLOCKS
| Clock ip name array for DMA. More...
#define | UART_CLOCKS
| Clock ip name array for UART. More...
#define | TPM_CLOCKS
| Clock ip name array for TPM. More...
#define | I2C_CLOCKS
| Clock ip name array for I2C. More...
#define | FTF_CLOCKS
| Clock ip name array for FTF. More...
#define | CMP_CLOCKS
| Clock ip name array for CMP. More...
#define | LPO_CLK_FREQ 1000U
| LPO clock frequency.
#define | SYS_CLK kCLOCK_CoreSysClk
| Peripherals clock source definition. More...

## Enumerations
enum | clock_name_t { kCLOCK_CoreSysClk, kCLOCK_PlatClk, kCLOCK_BusClk, kCLOCK_FlexBusClk, kCLOCK_FlashClk, kCLOCK_FastPeriphClk, kCLOCK_PllFllSelClk, kCLOCK_Er32kClk, kCLOCK_Osc0ErClk, kCLOCK_Osc1ErClk, kCLOCK_Osc0ErClkUndiv, kCLOCK_McgFixedFreqClk, kCLOCK_McgInternalRefClk, kCLOCK_McgFllClk, kCLOCK_McgPll0Clk, kCLOCK_McgPll1Clk, kCLOCK_McgExtPllClk, kCLOCK_McgPeriphClk, kCLOCK_McgIrc48MClk, kCLOCK_LpoClk }
| Clock name used to get clock frequency. More...
enum | clock_usb_src_t { kCLOCK_UsbSrcIrc48M = SIM_SOPT2_USBSRC(1U), kCLOCK_UsbSrcExt = SIM_SOPT2_USBSRC(0U) }
| USB clock source definition. More...
enum | clock_ip_name_t
| Clock gate name used for CLOCK_EnableClock/CLOCK_DisableClock. More...
enum | _osc_cap_load { kOSC_Cap2P = OSC_CR_SC2P_MASK, kOSC_Cap4P = OSC_CR_SC4P_MASK, kOSC_Cap8P = OSC_CR_SC8P_MASK, kOSC_Cap16P = OSC_CR_SC16P_MASK }
| Oscillator capacitor load setting. More...
enum | _oscer_enable_mode { kOSC_ErClkEnable = OSC_CR_ERCLKEN_MASK, kOSC_ErClkEnableInStop = OSC_CR_EREFSTEN_MASK }
| OSCERCLK enable mode. More...
enum | osc_mode_t { kOSC_ModeExt = 0U, kOSC_ModeOscLowPower = MCG_C2_EREFS0_MASK, kOSC_ModeOscHighGain = MCG_C2_EREFS0_MASK | MCG_C2_HGO0_MASK }
| OSC work mode. More...
enum | mcglite_clkout_src_t { kMCGLITE_ClkSrcHirc, kMCGLITE_ClkSrcLirc, kMCGLITE_ClkSrcExt }
| MCG_Lite clock source selection. More...
enum | mcglite_lirc_mode_t { kMCGLITE_Lirc2M, kMCGLITE_Lirc8M }
| MCG_Lite LIRC select. More...
enum | mcglite_lirc_div_t { kMCGLITE_LircDivBy1 = 0U, kMCGLITE_LircDivBy2, kMCGLITE_LircDivBy4, kMCGLITE_LircDivBy8, kMCGLITE_LircDivBy16, kMCGLITE_LircDivBy32, kMCGLITE_LircDivBy64, kMCGLITE_LircDivBy128 }
| MCG_Lite divider factor selection for clock source. More...
enum | mcglite_mode_t { kMCGLITE_ModeHirc48M, kMCGLITE_ModeLirc8M, kMCGLITE_ModeLirc2M, kMCGLITE_ModeExt, kMCGLITE_ModeError }
| MCG_Lite clock mode definitions. More...
enum | _mcglite_irclk_enable_mode { kMCGLITE_IrclkEnable = MCG_C1_IRCLKEN_MASK, kMCGLITE_IrclkEnableInStop = MCG_C1_IREFSTEN_MASK }
| MCG internal reference clock (MCGIRCLK) enable mode definition. More...

## Functions
static void | CLOCK_SetXtal0Freq (uint32_t freq)
| Set the XTAL0 frequency based on board setting. More...
static void | CLOCK_SetXtal32Freq (uint32_t freq)
| Set the XTAL32/RTC_CLKIN frequency based on board setting. More...
static void | CLOCK_EnableClock (clock_ip_name_t name)
| Enable the clock for specific IP. More...
static void | CLOCK_DisableClock (clock_ip_name_t name)
| Disable the clock for specific IP. More...
static void | CLOCK_SetEr32kClock (uint32_t src)
| Set ERCLK32K source. More...
static void | CLOCK_SetLpuart0Clock (uint32_t src)
| Set LPUART0 clock source. More...
static void | CLOCK_SetLpuart1Clock (uint32_t src)
| Set LPUART1 clock source. More...
static void | CLOCK_SetTpmClock (uint32_t src)
| Set TPM clock source. More...
static void | CLOCK_SetFlexio0Clock (uint32_t src)
| Set FLEXIO clock source. More...
bool | CLOCK_EnableUsbfs0Clock (clock_usb_src_t src, uint32_t freq)
| Enable USB FS clock. More...
static void | CLOCK_DisableUsbfs0Clock (void)
| Disable USB FS clock. More...
static void | CLOCK_SetClkOutClock (uint32_t src)
| Set CLKOUT source. More...
static void | CLOCK_SetRtcClkOutClock (uint32_t src)
| Set RTC_CLKOUT source. More...
static void | CLOCK_SetOutDiv (uint32_t outdiv1, uint32_t outdiv4)
| System clock divider. More...
uint32_t | CLOCK_GetFreq (clock_name_t clockName)
| Gets the clock frequency for a specific clock name. More...
uint32_t | CLOCK_GetCoreSysClkFreq (void)
| Get the core clock or system clock frequency. More...
uint32_t | CLOCK_GetPlatClkFreq (void)
| Get the platform clock frequency. More...
uint32_t | CLOCK_GetBusClkFreq (void)
| Get the bus clock frequency. More...
uint32_t | CLOCK_GetFlashClkFreq (void)
| Get the flash clock frequency. More...
uint32_t | CLOCK_GetEr32kClkFreq (void)
| Get the external reference 32K clock frequency (ERCLK32K). More...
uint32_t | CLOCK_GetOsc0ErClkFreq (void)
| Get the OSC0 external reference clock frequency (OSC0ERCLK). More...
void | CLOCK_SetSimConfig (sim_clock_config_t const *config)
| Set the clock configure in SIM module. More...
static void | CLOCK_SetSimSafeDivs (void)
| Set the system clock dividers in SIM to safe value. More...

## Variables
uint32_t | g_xtal0Freq
| External XTAL0 (OSC0) clock frequency. More...
uint32_t | g_xtal32Freq
| External XTAL32/EXTAL32/RTC_CLKIN clock frequency. More...

## MCG_Lite clock frequency
uint32_t | CLOCK_GetOutClkFreq (void)
| Gets the MCG_Lite output clock (MCGOUTCLK) frequency. More...
uint32_t | CLOCK_GetInternalRefClkFreq (void)
| Gets the MCG internal reference clock (MCGIRCLK) frequency. More...
uint32_t | CLOCK_GetPeriphClkFreq (void)
| Gets the current MCGPCLK frequency. More...

## MCG_Lite mode.
mcglite_mode_t | CLOCK_GetMode (void)
| Gets the current MCG_Lite mode. More...
status_t | CLOCK_SetMcgliteConfig (mcglite_config_t const *targetConfig)
| Sets the MCG_Lite configuration. More...

## OSC configuration
static void | OSC_SetExtRefClkConfig (OSC_Type *base, oscer_config_t const *config)
| Configures the OSC external reference clock (OSCERCLK). More...
static void | OSC_SetCapLoad (OSC_Type *base, uint8_t capLoad)
| Sets the capacitor load configuration for the oscillator. More...
void | CLOCK_InitOsc0 (osc_config_t const *config)
| Initialize OSC0. More...
void | CLOCK_DeinitOsc0 (void)
| Deinitializes the OSC0. More...

## Data Structure Documentation

struct sim_clock_config_t

### Data Fields
uint8_t | er32kSrc
| ERCLK32K source selection. More...
uint32_t | clkdiv1
| SIM_CLKDIV1. More...

#### Field Documentation

uint8_t sim_clock_config_t::er32kSrc

uint32_t sim_clock_config_t::clkdiv1

struct oscer_config_t

### Data Fields
uint8_t | enableMode
| OSCERCLK enable mode. More...

#### Field Documentation

uint8_t oscer_config_t::enableMode

OR'ed value of _oscer_enable_mode.

struct osc_config_t

Defines the configuration data structure to initialize the OSC. When porting to a new board, set the following members according to board settings:

1. freq: The external frequency.
2. workMode: The OSC module mode.

### Data Fields
uint32_t | freq
| External clock frequency. More...
uint8_t | capLoad
| Capacitor load setting. More...
osc_mode_t | workMode
| OSC work mode setting. More...
oscer_config_t | oscerConfig
| Configuration for OSCERCLK. More...

#### Field Documentation

uint32_t osc_config_t::freq

uint8_t osc_config_t::capLoad

osc_mode_t osc_config_t::workMode

oscer_config_t osc_config_t::oscerConfig

struct mcglite_config_t

### Data Fields
mcglite_clkout_src_t | outSrc
| MCGOUT clock select. More...
uint8_t | irclkEnableMode
| MCGIRCLK enable mode, OR'ed value of _mcglite_irclk_enable_mode. More...
mcglite_lirc_mode_t | ircs
| MCG_C2[IRCS]. More...
mcglite_lirc_div_t | fcrdiv
| MCG_SC[FCRDIV]. More...
mcglite_lirc_div_t | lircDiv2
| MCG_MC[LIRC_DIV2]. More...
bool | hircEnableInNotHircMode
| HIRC enable when not in HIRC mode. More...

#### Field Documentation

mcglite_clkout_src_t mcglite_config_t::outSrc

uint8_t mcglite_config_t::irclkEnableMode

mcglite_lirc_mode_t mcglite_config_t::ircs

mcglite_lirc_div_t mcglite_config_t::fcrdiv

mcglite_lirc_div_t mcglite_config_t::lircDiv2

bool mcglite_config_t::hircEnableInNotHircMode

## Macro Definition Documentation

#define FSL_CLOCK_DRIVER_VERSION (MAKE_VERSION(2, 1, 0))

Version 2.1.0.

#define DMAMUX_CLOCKS

Value:
{ \
kCLOCK_Dmamux0 \
}

#define RTC_CLOCKS

Value:
{ \
kCLOCK_Rtc0 \
}

#define SAI_CLOCKS

Value:
{ \
kCLOCK_Sai0 \
}

#define SPI_CLOCKS

Value:
{ \
kCLOCK_Spi0, kCLOCK_Spi1 \
}

#define SLCD_CLOCKS

Value:
{ \
kCLOCK_Slcd0 \
}

#define PIT_CLOCKS

Value:
{ \
kCLOCK_Pit0 \
}

#define PORT_CLOCKS

Value:
{ \
kCLOCK_PortA, kCLOCK_PortB, kCLOCK_PortC, kCLOCK_PortD, kCLOCK_PortE \
}

#define LPUART_CLOCKS

Value:
{ \
kCLOCK_Lpuart0, kCLOCK_Lpuart1 \
}

#define DAC_CLOCKS

Value:
{ \
kCLOCK_Dac0 \
}

#define LPTMR_CLOCKS

Value:
{ \
kCLOCK_Lptmr0 \
}

#define ADC16_CLOCKS

Value:
{ \
kCLOCK_Adc0 \
}

#define FLEXIO_CLOCKS

Value:
{ \
kCLOCK_Flexio0 \
}

#define VREF_CLOCKS

Value:
{ \
kCLOCK_Vref0 \
}

#define DMA_CLOCKS

Value:
{ \
kCLOCK_Dma0 \
}

#define UART_CLOCKS

Value:
{ \
kCLOCK_IpInvalid, kCLOCK_IpInvalid, kCLOCK_Uart2 \
}

#define TPM_CLOCKS

Value:
{ \
kCLOCK_Tpm0, kCLOCK_Tpm1, kCLOCK_Tpm2 \
}

#define I2C_CLOCKS

Value:
{ \
kCLOCK_I2c0, kCLOCK_I2c1 \
}

#define FTF_CLOCKS

Value:
{ \
kCLOCK_Ftf0 \
}

#define CMP_CLOCKS

Value:
{ \
kCLOCK_Cmp0, kCLOCK_Cmp1, kCLOCK_Cmp2 \
}

#define SYS_CLK kCLOCK_CoreSysClk

## Enumeration Type Documentation

enum clock_name_t

Enumerator
kCLOCK_CoreSysClk | Core/system clock.
kCLOCK_PlatClk | Platform clock.
kCLOCK_BusClk | Bus clock.
kCLOCK_FlexBusClk | FlexBus clock.
kCLOCK_FlashClk | Flash clock.
kCLOCK_FastPeriphClk | Fast peripheral clock.
kCLOCK_PllFllSelClk | The clock after SIM[PLLFLLSEL].
kCLOCK_Er32kClk | External reference 32K clock (ERCLK32K)
kCLOCK_Osc0ErClk | OSC0 external reference clock (OSC0ERCLK)
kCLOCK_Osc1ErClk | OSC1 external reference clock (OSC1ERCLK)
kCLOCK_Osc0ErClkUndiv | OSC0 external reference undivided clock(OSC0ERCLK_UNDIV).
kCLOCK_McgFixedFreqClk | MCG fixed frequency clock (MCGFFCLK)
kCLOCK_McgInternalRefClk | MCG internal reference clock (MCGIRCLK)
kCLOCK_McgFllClk | MCGFLLCLK.
kCLOCK_McgPll0Clk | MCGPLL0CLK.
kCLOCK_McgPll1Clk | MCGPLL1CLK.
kCLOCK_McgExtPllClk | EXT_PLLCLK.
kCLOCK_McgPeriphClk | MCG peripheral clock (MCGPCLK)
kCLOCK_McgIrc48MClk | MCG IRC48M clock.
kCLOCK_LpoClk | LPO clock.

enum clock_usb_src_t

Enumerator
kCLOCK_UsbSrcIrc48M | Use IRC48M.
kCLOCK_UsbSrcExt | Use USB_CLKIN.

enum clock_ip_name_t

enum _osc_cap_load

Enumerator
kOSC_Cap2P | 2 pF capacitor load
kOSC_Cap4P | 4 pF capacitor load
kOSC_Cap8P | 8 pF capacitor load
kOSC_Cap16P | 16 pF capacitor load

enum _oscer_enable_mode

Enumerator
kOSC_ErClkEnable | Enable.
kOSC_ErClkEnableInStop | Enable in stop mode.

enum osc_mode_t

Enumerator
kOSC_ModeExt | Use external clock.
kOSC_ModeOscLowPower | Oscillator low power.
kOSC_ModeOscHighGain | Oscillator high gain.

enum mcglite_clkout_src_t

Enumerator
kMCGLITE_ClkSrcHirc | MCGOUTCLK source is HIRC.
kMCGLITE_ClkSrcLirc | MCGOUTCLK source is LIRC.
kMCGLITE_ClkSrcExt | MCGOUTCLK source is external clock source.

enum mcglite_lirc_mode_t

Enumerator
kMCGLITE_Lirc2M | Slow internal reference(LIRC) 2MHz clock selected.
kMCGLITE_Lirc8M | Slow internal reference(LIRC) 8MHz clock selected.

enum mcglite_lirc_div_t

Enumerator
kMCGLITE_LircDivBy1 | Divider is 1.
kMCGLITE_LircDivBy2 | Divider is 2.
kMCGLITE_LircDivBy4 | Divider is 4.
kMCGLITE_LircDivBy8 | Divider is 8.
kMCGLITE_LircDivBy16 | Divider is 16.
kMCGLITE_LircDivBy32 | Divider is 32.
kMCGLITE_LircDivBy64 | Divider is 64.
kMCGLITE_LircDivBy128 | Divider is 128.

enum mcglite_mode_t

Enumerator
kMCGLITE_ModeHirc48M | Clock mode is HIRC 48 M.
kMCGLITE_ModeLirc8M | Clock mode is LIRC 8 M.
kMCGLITE_ModeLirc2M | Clock mode is LIRC 2 M.
kMCGLITE_ModeExt | Clock mode is EXT.
kMCGLITE_ModeError | Unknown mode.

enum _mcglite_irclk_enable_mode

Enumerator
kMCGLITE_IrclkEnable | MCGIRCLK enable.
kMCGLITE_IrclkEnableInStop | MCGIRCLK enable in stop mode.

## Function Documentation

static void CLOCK_SetXtal0Freq | ( | uint32_t | freq | ) |
| inline static

Parameters

  freq | The XTAL0/EXTAL0 input clock frequency in Hz.

static void CLOCK_SetXtal32Freq | ( | uint32_t | freq | ) |
| inline static

Parameters

  freq | The XTAL32/EXTAL32/RTC_CLKIN input clock frequency in Hz.

static void CLOCK_EnableClock | ( | clock_ip_name_t | name | ) |
| inline static

Parameters

  name | Which clock to enable, see clock_ip_name_t.

static void CLOCK_DisableClock | ( | clock_ip_name_t | name | ) |
| inline static

Parameters

  name | Which clock to disable, see clock_ip_name_t.

static void CLOCK_SetEr32kClock | ( | uint32_t | src | ) |
| inline static

Parameters

  src | The value to set ERCLK32K clock source.

static void CLOCK_SetLpuart0Clock | ( | uint32_t | src | ) |
| inline static

Parameters

  src | The value to set LPUART0 clock source.

static void CLOCK_SetLpuart1Clock | ( | uint32_t | src | ) |
| inline static

Parameters

  src | The value to set LPUART1 clock source.

static void CLOCK_SetTpmClock | ( | uint32_t | src | ) |
| inline static

Parameters

  src | The value to set TPM clock source.

static void CLOCK_SetFlexio0Clock | ( | uint32_t | src | ) |
| inline static

Parameters

  src | The value to set FLEXIO clock source.

bool CLOCK_EnableUsbfs0Clock | ( | clock_usb_src_t | src,
|  | uint32_t | freq
| ) |  |

Parameters

  src | USB FS clock source.
  freq | The frequency specified by src.

Return values

  true | The clock is set successfully.
  false | The clock source is invalid to get proper USB FS clock.

static void CLOCK_DisableUsbfs0Clock | ( | void |  | ) |
| inline static

Disable USB FS clock.

static void CLOCK_SetClkOutClock | ( | uint32_t | src | ) |
| inline static

Parameters

  src | The value to set CLKOUT source.

static void CLOCK_SetRtcClkOutClock | ( | uint32_t | src | ) |
| inline static

Parameters

  src | The value to set RTC_CLKOUT source.

static void CLOCK_SetOutDiv | ( | uint32_t | outdiv1,
|  | uint32_t | outdiv4
| ) |  |
| inline static

Set the SIM_CLKDIV1[OUTDIV1], SIM_CLKDIV1[OUTDIV4].

Parameters

  outdiv1 | Clock 1 output divider value.
  outdiv4 | Clock 4 output divider value.

uint32_t CLOCK_GetFreq | ( | clock_name_t | clockName | ) |

This function checks the current clock configurations and then calculates the clock frequency for a specific clock name defined in clock_name_t. The MCG must be properly configured before using this function.

Parameters

  clockName | Clock names defined in clock_name_t

Returns
  Clock frequency value in Hertz

uint32_t CLOCK_GetCoreSysClkFreq | ( | void |  | ) |

Returns
  Clock frequency in Hz.

uint32_t CLOCK_GetPlatClkFreq | ( | void |  | ) |

Returns
  Clock frequency in Hz.

uint32_t CLOCK_GetBusClkFreq | ( | void |  | ) |

Returns
  Clock frequency in Hz.

uint32_t CLOCK_GetFlashClkFreq | ( | void |  | ) |

Returns
  Clock frequency in Hz.

uint32_t CLOCK_GetEr32kClkFreq | ( | void |  | ) |

Returns
  Clock frequency in Hz.

uint32_t CLOCK_GetOsc0ErClkFreq | ( | void |  | ) |

Returns
  Clock frequency in Hz.

void CLOCK_SetSimConfig | ( | sim_clock_config_t const * | config | ) |

This function sets system layer clock settings in SIM module.

Parameters

  config | Pointer to the configure structure.

static void CLOCK_SetSimSafeDivs | ( | void |  | ) |
| inline static

The system level clocks (core clock, bus clock, flexbus clock and flash clock) must be in allowed ranges. During MCG clock mode switch, the MCG output clock changes then the system level clocks may be out of range. This function could be used before MCG mode change, to make sure system level clocks are in allowed range.

Parameters

  config | Pointer to the configure structure.

uint32_t CLOCK_GetOutClkFreq | ( | void |  | ) |

This function gets the MCG_Lite output clock frequency (Hz) based on the current MCG_Lite register value.

Returns
  The frequency of MCGOUTCLK.

uint32_t CLOCK_GetInternalRefClkFreq | ( | void |  | ) |

This function gets the MCG_Lite internal reference clock frequency (Hz) based on the current MCG register value.

Returns
  The frequency of MCGIRCLK.

uint32_t CLOCK_GetPeriphClkFreq | ( | void |  | ) |

This function gets the MCGPCLK frequency (Hertz) based on the current MCG_Lite register settings.

Returns
  The frequency of MCGPCLK.

mcglite_mode_t CLOCK_GetMode | ( | void |  | ) |

This function checks the MCG_Lite registers and determines the current MCG_Lite mode.

Returns
  Current MCG_Lite mode or error code.

status_t CLOCK_SetMcgliteConfig | ( | mcglite_config_t const * | targetConfig | ) |

This function configures the MCG_Lite, include output clock source, MCGIRCLK setting, HIRC setting and so on, see mcglite_config_t for details.

Parameters

  targetConfig | Pointer to the target MCG_Lite mode configuration structure.

Returns
  Error code.

static void OSC_SetExtRefClkConfig | ( | OSC_Type * | base,
|  | oscer_config_t const * | config
| ) |  |
| inline static

This function configures the OSC external reference clock (OSCERCLK). For example, to enable the OSCERCLK in normal mode and stop mode, and also set the output divider to 1, as follows:

oscer_config_t config =
{
.enableMode = kOSC_ErClkEnable | kOSC_ErClkEnableInStop,
.erclkDiv = 1U,
};
OSC_SetExtRefClkConfig(OSC, &config);

Parameters

  base | OSC peripheral address.
  config | Pointer to the configuration structure.

static void OSC_SetCapLoad | ( | OSC_Type * | base,
|  | uint8_t | capLoad
| ) |  |
| inline static

This function sets the specified capacitors configuration for the oscillator. This should be done in the early system level initialization function call based on the system configuration.

Parameters

  base | OSC peripheral address.
  capLoad | OR'ed value for the capacitor load option, see _osc_cap_load.

Example:

// To enable only 2 pF and 8 pF capacitor load, please use like this.
OSC_SetCapLoad(OSC, kOSC_Cap2P | kOSC_Cap8P);

void CLOCK_InitOsc0 | ( | osc_config_t const * | config | ) |

This function initializes the OSC0 according to the board configuration.

Parameters

  config | Pointer to the OSC0 configuration structure.

void CLOCK_DeinitOsc0 | ( | void |  | ) |

This function deinitializes the OSC0.

## Variable Documentation

uint32_t g_xtal0Freq

The XTAL0/EXTAL0 (OSC0) clock frequency in Hz, when the clock is setup, use the function CLOCK_SetXtal0Freq to set the value in to clock driver. For example, if XTAL0 is 8MHz,

CLOCK_InitOsc0(...); // Setup the OSC0
CLOCK_SetXtal0Freq(80000000); // Set the XTAL0 value to clock driver.

This is important for the multicore platforms, only one core needs to setup OSC0 using CLOCK_InitOsc0, all other cores need to call CLOCK_SetXtal0Freq to get valid clock frequency.

uint32_t g_xtal32Freq

The XTAL32/EXTAL32/RTC_CLKIN clock frequency in Hz, when the clock is setup, use the function CLOCK_SetXtal32Freq to set the value in to clock driver.

This is important for the multicore platforms, only one core needs to setup the clock, all other cores need to call CLOCK_SetXtal32Freq to get valid clock frequency.