MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Clock Driver

Overview

The MCUXpresso SDK provides APIs for MCUXpresso SDK devices' clock operation.

Modules

 System Clock Generator (SCG)
 

Files

file  fsl_clock.h
 

Data Structures

struct  scg_sys_clk_config_t
 SCG system clock configuration. More...
 
struct  scg_sosc_config_t
 SCG system OSC configuration. More...
 
struct  scg_sirc_config_t
 SCG slow IRC clock configuration. More...
 
struct  scg_firc_trim_config_t
 SCG fast IRC clock trim configuration. More...
 
struct  scg_firc_config_t
 SCG fast IRC clock configuration. More...
 
struct  scg_lpfll_trim_config_t
 SCG LPFLL clock trim configuration. More...
 
struct  scg_lpfll_config_t
 SCG low power FLL configuration. More...
 

Macros

#define FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL   0
 Configure whether driver controls clock. More...
 
#define RTC_CLOCKS
 Clock ip name array for RTC. More...
 
#define PORT_CLOCKS
 Clock ip name array for PORT. More...
 
#define LPI2C_CLOCKS
 Clock ip name array for LPI2C. More...
 
#define TSI_CLOCKS
 Clock ip name array for TSI. More...
 
#define LPUART_CLOCKS
 Clock ip name array for LPUART. More...
 
#define LPTMR_CLOCKS
 Clock ip name array for LPTMR. More...
 
#define ADC12_CLOCKS
 Clock ip name array for ADC12. More...
 
#define LPSPI_CLOCKS
 Clock ip name array for LPSPI. More...
 
#define LPIT_CLOCKS
 Clock ip name array for LPIT. More...
 
#define CRC_CLOCKS
 Clock ip name array for CRC. More...
 
#define CMP_CLOCKS
 Clock ip name array for CMP. More...
 
#define FLASH_CLOCKS
 Clock ip name array for FLASH. More...
 
#define EWM_CLOCKS
 Clock ip name array for EWM. More...
 
#define FTM_CLOCKS
 Clock ip name array for FLEXTMR. More...
 
#define PDB_CLOCKS
 Clock ip name array for PDB. More...
 
#define PWT_CLOCKS
 Clock ip name array for PWT. More...
 
#define MSCAN_CLOCKS
 Clock ip name array for MSCAN. More...
 
#define LPO_CLK_FREQ   128000U
 LPO clock frequency.
 
#define CLOCK_GetOsc0ErClkFreq   CLOCK_GetErClkFreq
 For compatible with other MCG platforms. More...
 

Enumerations

enum  clock_name_t {
  kCLOCK_CoreSysClk,
  kCLOCK_BusClk,
  kCLOCK_FlashClk,
  kCLOCK_ScgSysOscClk,
  kCLOCK_ScgSircClk,
  kCLOCK_ScgFircClk,
  kCLOCK_ScgLpFllClk,
  kCLOCK_ScgSysOscAsyncDiv2Clk,
  kCLOCK_ScgSircAsyncDiv2Clk,
  kCLOCK_ScgFircAsyncDiv2Clk,
  kCLOCK_ScgLpFllAsyncDiv2Clk,
  kCLOCK_LpoClk,
  kCLOCK_ErClk
}
 Clock name used to get clock frequency. More...
 
enum  clock_ip_src_t {
  kCLOCK_IpSrcNoneOrExt = 0U,
  kCLOCK_IpSrcSysOscAsync = 1U,
  kCLOCK_IpSrcSircAsync = 2U,
  kCLOCK_IpSrcFircAsync = 3U,
  kCLOCK_IpSrcLpFllAsync = 5U
}
 Clock source for peripherals that support various clock selections. More...
 
enum  clock_ip_name_t
 Peripheral clock name difinition used for clock gate, clock source and clock divider setting. More...
 
enum  _scg_status {
  kStatus_SCG_Busy = MAKE_STATUS(kStatusGroup_SCG, 1),
  kStatus_SCG_InvalidSrc = MAKE_STATUS(kStatusGroup_SCG, 2)
}
 SCG status return codes. More...
 
enum  scg_sys_clk_t {
  kSCG_SysClkSlow,
  kSCG_SysClkCore
}
 SCG system clock type. More...
 
enum  scg_sys_clk_src_t {
  kSCG_SysClkSrcSysOsc = 1U,
  kSCG_SysClkSrcSirc = 2U,
  kSCG_SysClkSrcFirc = 3U,
  kSCG_SysClkSrcLpFll = 5U
}
 SCG system clock source. More...
 
enum  scg_sys_clk_div_t {
  kSCG_SysClkDivBy1 = 0U,
  kSCG_SysClkDivBy2 = 1U,
  kSCG_SysClkDivBy3 = 2U,
  kSCG_SysClkDivBy4 = 3U,
  kSCG_SysClkDivBy5 = 4U,
  kSCG_SysClkDivBy6 = 5U,
  kSCG_SysClkDivBy7 = 6U,
  kSCG_SysClkDivBy8 = 7U,
  kSCG_SysClkDivBy9 = 8U,
  kSCG_SysClkDivBy10 = 9U,
  kSCG_SysClkDivBy11 = 10U,
  kSCG_SysClkDivBy12 = 11U,
  kSCG_SysClkDivBy13 = 12U,
  kSCG_SysClkDivBy14 = 13U,
  kSCG_SysClkDivBy15 = 14U,
  kSCG_SysClkDivBy16 = 15U
}
 SCG system clock divider value. More...
 
enum  clock_clkout_src_t {
  kClockClkoutSelScgSlow = 0U,
  kClockClkoutSelSysOsc = 1U,
  kClockClkoutSelSirc = 2U,
  kClockClkoutSelFirc = 3U,
  kClockClkoutSelLpFll = 5U
}
 SCG clock out configuration (CLKOUTSEL). More...
 
enum  scg_async_clk_t {
  kSCG_AsyncDiv1Clk,
  kSCG_AsyncDiv2Clk
}
 SCG asynchronous clock type. More...
 
enum  scg_async_clk_div_t {
  kSCG_AsyncClkDisable = 0U,
  kSCG_AsyncClkDivBy1 = 1U,
  kSCG_AsyncClkDivBy2 = 2U,
  kSCG_AsyncClkDivBy4 = 3U,
  kSCG_AsyncClkDivBy8 = 4U,
  kSCG_AsyncClkDivBy16 = 5U,
  kSCG_AsyncClkDivBy32 = 6U,
  kSCG_AsyncClkDivBy64 = 7U
}
 SCG asynchronous clock divider value. More...
 
enum  scg_sosc_monitor_mode_t {
  kSCG_SysOscMonitorDisable = 0U,
  kSCG_SysOscMonitorInt = SCG_SOSCCSR_SOSCCM_MASK,
  kSCG_SysOscMonitorReset
}
 SCG system OSC monitor mode. More...
 
enum  scg_sosc_mode_t {
  kSCG_SysOscModeExt = 0U,
  kSCG_SysOscModeOscLowPower = SCG_SOSCCFG_EREFS_MASK,
  kSCG_SysOscModeOscHighGain = SCG_SOSCCFG_EREFS_MASK | SCG_SOSCCFG_HGO_MASK
}
 OSC work mode. More...
 
enum  _scg_sosc_enable_mode {
  kSCG_SysOscEnable = SCG_SOSCCSR_SOSCEN_MASK,
  kSCG_SysOscEnableInStop = SCG_SOSCCSR_SOSCSTEN_MASK,
  kSCG_SysOscEnableInLowPower = SCG_SOSCCSR_SOSCLPEN_MASK,
  kSCG_SysOscEnableErClk = SCG_SOSCCSR_SOSCERCLKEN_MASK
}
 OSC enable mode. More...
 
enum  scg_sirc_range_t {
  kSCG_SircRangeLow,
  kSCG_SircRangeHigh
}
 SCG slow IRC clock frequency range. More...
 
enum  _scg_sirc_enable_mode {
  kSCG_SircEnable = SCG_SIRCCSR_SIRCEN_MASK,
  kSCG_SircEnableInStop = SCG_SIRCCSR_SIRCSTEN_MASK,
  kSCG_SircEnableInLowPower = SCG_SIRCCSR_SIRCLPEN_MASK
}
 SIRC enable mode. More...
 
enum  scg_firc_trim_mode_t {
  kSCG_FircTrimNonUpdate = SCG_FIRCCSR_FIRCTREN_MASK,
  kSCG_FircTrimUpdate = SCG_FIRCCSR_FIRCTREN_MASK | SCG_FIRCCSR_FIRCTRUP_MASK
}
 SCG fast IRC trim mode. More...
 
enum  scg_firc_trim_div_t {
  kSCG_FircTrimDivBy1,
  kSCG_FircTrimDivBy128,
  kSCG_FircTrimDivBy256,
  kSCG_FircTrimDivBy512,
  kSCG_FircTrimDivBy1024,
  kSCG_FircTrimDivBy2048
}
 SCG fast IRC trim predivided value for system OSC. More...
 
enum  scg_firc_trim_src_t { kSCG_FircTrimSrcSysOsc = 2U }
 SCG fast IRC trim source. More...
 
enum  scg_firc_range_t {
  kSCG_FircRange48M,
  kSCG_FircRange52M,
  kSCG_FircRange56M,
  kSCG_FircRange60M
}
 SCG fast IRC clock frequency range. More...
 
enum  _scg_firc_enable_mode {
  kSCG_FircEnable = SCG_FIRCCSR_FIRCEN_MASK,
  kSCG_FircEnableInStop = SCG_FIRCCSR_FIRCSTEN_MASK,
  kSCG_FircEnableInLowPower = SCG_FIRCCSR_FIRCLPEN_MASK,
  kSCG_FircDisableRegulator = SCG_FIRCCSR_FIRCREGOFF_MASK
}
 FIRC enable mode. More...
 
enum  _scg_lpfll_enable_mode { kSCG_LpFllEnable = SCG_LPFLLCSR_LPFLLEN_MASK }
 LPFLL enable mode. More...
 
enum  scg_lpfll_range_t {
  kSCG_LpFllRange48M,
  kSCG_LpFllRange72M,
  kSCG_LpFllRange96M,
  kSCG_LpFllRange120M
}
 SCG LPFLL clock frequency range. More...
 
enum  scg_lpfll_trim_mode_t {
  kSCG_LpFllTrimNonUpdate = SCG_LPFLLCSR_LPFLLTREN_MASK,
  kSCG_LpFllTrimUpdate = SCG_LPFLLCSR_LPFLLTREN_MASK | SCG_LPFLLCSR_LPFLLTRUP_MASK
}
 SCG LPFLL trim mode. More...
 
enum  scg_lpfll_trim_src_t {
  kSCG_LpFllTrimSrcSirc = 0U,
  kSCG_LpFllTrimSrcFirc = 1U,
  kSCG_LpFllTrimSrcSysOsc = 2U,
  kSCG_LpFllTrimSrcRtcOsc = 3U
}
 SCG LPFLL trim source. More...
 
enum  scg_lpfll_lock_mode_t {
  kSCG_LpFllLock1Lsb = 0U,
  kSCG_LpFllLock2Lsb = 1U
}
 SCG LPFLL lock mode. More...
 

Functions

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_SetIpSrc (clock_ip_name_t name, clock_ip_src_t src)
 Set the clock source for specific IP module. 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_GetBusClkFreq (void)
 Get the bus clock frequency. More...
 
uint32_t CLOCK_GetFlashClkFreq (void)
 Get the flash clock frequency. More...
 
uint32_t CLOCK_GetErClkFreq (void)
 Get the external reference clock frequency (ERCLK). More...
 
uint32_t CLOCK_GetIpFreq (clock_ip_name_t name)
 Gets the clock frequency for a specific IP module. More...
 

Variables

volatile uint32_t g_xtal0Freq
 External XTAL0 (OSC0/SYSOSC) clock frequency. More...
 

Driver version

#define FSL_CLOCK_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 CLOCK driver version 2.0.0. More...
 

MCU System Clock.

uint32_t CLOCK_GetSysClkFreq (scg_sys_clk_t type)
 Gets the SCG system clock frequency. More...
 
static void CLOCK_SetVlprModeSysClkConfig (const scg_sys_clk_config_t *config)
 Sets the system clock configuration for VLPR mode. More...
 
static void CLOCK_SetRunModeSysClkConfig (const scg_sys_clk_config_t *config)
 Sets the system clock configuration for RUN mode. More...
 
static void CLOCK_GetCurSysClkConfig (scg_sys_clk_config_t *config)
 Gets the system clock configuration in the current power mode. More...
 
static void CLOCK_SetClkOutSel (clock_clkout_src_t setting)
 Sets the clock out selection. More...
 

SCG System OSC Clock.

status_t CLOCK_InitSysOsc (const scg_sosc_config_t *config)
 Initializes the SCG system OSC. More...
 
status_t CLOCK_DeinitSysOsc (void)
 De-initializes the SCG system OSC. More...
 
static void CLOCK_SetSysOscAsyncClkDiv (scg_async_clk_t asyncClk, scg_async_clk_div_t divider)
 Set the asynchronous clock divider. More...
 
uint32_t CLOCK_GetSysOscFreq (void)
 Gets the SCG system OSC clock frequency (SYSOSC). More...
 
uint32_t CLOCK_GetSysOscAsyncFreq (scg_async_clk_t type)
 Gets the SCG asynchronous clock frequency from the system OSC. More...
 
static bool CLOCK_IsSysOscErr (void)
 Checks whether the system OSC clock error occurs. More...
 
static void CLOCK_ClearSysOscErr (void)
 Clears the system OSC clock error.
 
static void CLOCK_SetSysOscMonitorMode (scg_sosc_monitor_mode_t mode)
 Sets the system OSC monitor mode. More...
 
static bool CLOCK_IsSysOscValid (void)
 Checks whether the system OSC clock is valid. More...
 

SCG Slow IRC Clock.

status_t CLOCK_InitSirc (const scg_sirc_config_t *config)
 Initializes the SCG slow IRC clock. More...
 
status_t CLOCK_DeinitSirc (void)
 De-initializes the SCG slow IRC. More...
 
static void CLOCK_SetSircAsyncClkDiv (scg_async_clk_t asyncClk, scg_async_clk_div_t divider)
 Set the asynchronous clock divider. More...
 
uint32_t CLOCK_GetSircFreq (void)
 Gets the SCG SIRC clock frequency. More...
 
uint32_t CLOCK_GetSircAsyncFreq (scg_async_clk_t type)
 Gets the SCG asynchronous clock frequency from the SIRC. More...
 
static bool CLOCK_IsSircValid (void)
 Checks whether the SIRC clock is valid. More...
 

SCG Fast IRC Clock.

status_t CLOCK_InitFirc (const scg_firc_config_t *config)
 Initializes the SCG fast IRC clock. More...
 
status_t CLOCK_DeinitFirc (void)
 De-initializes the SCG fast IRC. More...
 
static void CLOCK_SetFircAsyncClkDiv (scg_async_clk_t asyncClk, scg_async_clk_div_t divider)
 Set the asynchronous clock divider. More...
 
uint32_t CLOCK_GetFircFreq (void)
 Gets the SCG FIRC clock frequency. More...
 
uint32_t CLOCK_GetFircAsyncFreq (scg_async_clk_t type)
 Gets the SCG asynchronous clock frequency from the FIRC. More...
 
static bool CLOCK_IsFircErr (void)
 Checks whether the FIRC clock error occurs. More...
 
static void CLOCK_ClearFircErr (void)
 Clears the FIRC clock error.
 
static bool CLOCK_IsFircValid (void)
 Checks whether the FIRC clock is valid. More...
 

SCG Low Power FLL Clock.

status_t CLOCK_InitLpFll (const scg_lpfll_config_t *config)
 Initializes the SCG LPFLL clock. More...
 
status_t CLOCK_DeinitLpFll (void)
 De-initializes the SCG LPFLL. More...
 
static void CLOCK_SetLpFllAsyncClkDiv (scg_async_clk_t asyncClk, scg_async_clk_div_t divider)
 Set the asynchronous clock divider. More...
 
uint32_t CLOCK_GetLpFllFreq (void)
 Gets the SCG LPFLL clock frequency. More...
 
uint32_t CLOCK_GetLpFllAsyncFreq (scg_async_clk_t type)
 Gets the SCG asynchronous clock frequency from the LPFLL. More...
 
static bool CLOCK_IsLpFllValid (void)
 Checks whether the LPFLL clock is valid. More...
 

External clock frequency

static void CLOCK_SetXtal0Freq (uint32_t freq)
 Sets the XTAL0 frequency based on board settings. More...
 

Data Structure Documentation

struct scg_sys_clk_config_t

Data Fields

uint32_t divSlow: 4
 Slow clock divider, see scg_sys_clk_div_t. More...
 
uint32_t __pad0__: 4
 Reserved. More...
 
uint32_t __pad1__: 4
 Reserved. More...
 
uint32_t __pad2__: 4
 Reserved. More...
 
uint32_t divCore: 4
 Core clock divider, see scg_sys_clk_div_t. More...
 
uint32_t __pad3__: 4
 Reserved. More...
 
uint32_t src: 4
 System clock source, see scg_sys_clk_src_t. More...
 
uint32_t __pad4__: 4
 reserved. More...
 

Field Documentation

uint32_t scg_sys_clk_config_t::divSlow
uint32_t scg_sys_clk_config_t::__pad0__
uint32_t scg_sys_clk_config_t::__pad1__
uint32_t scg_sys_clk_config_t::__pad2__
uint32_t scg_sys_clk_config_t::divCore
uint32_t scg_sys_clk_config_t::__pad3__
uint32_t scg_sys_clk_config_t::src
uint32_t scg_sys_clk_config_t::__pad4__
struct scg_sosc_config_t

Data Fields

uint32_t freq
 System OSC frequency. More...
 
scg_sosc_monitor_mode_t monitorMode
 Clock monitor mode selected. More...
 
uint8_t enableMode
 Enable mode, OR'ed value of _scg_sosc_enable_mode. More...
 
scg_async_clk_div_t div1
 SOSCDIV1 value. More...
 
scg_async_clk_div_t div2
 SOSCDIV2 value. More...
 
scg_sosc_mode_t workMode
 OSC work mode. More...
 

Field Documentation

uint32_t scg_sosc_config_t::freq
scg_sosc_monitor_mode_t scg_sosc_config_t::monitorMode
uint8_t scg_sosc_config_t::enableMode
scg_async_clk_div_t scg_sosc_config_t::div1
scg_async_clk_div_t scg_sosc_config_t::div2
scg_sosc_mode_t scg_sosc_config_t::workMode
struct scg_sirc_config_t

Data Fields

uint32_t enableMode
 Enable mode, OR'ed value of _scg_sirc_enable_mode. More...
 
scg_async_clk_div_t div1
 SIRCDIV1 value. More...
 
scg_async_clk_div_t div2
 SIRCDIV2 value. More...
 
scg_sirc_range_t range
 Slow IRC frequency range. More...
 

Field Documentation

uint32_t scg_sirc_config_t::enableMode
scg_async_clk_div_t scg_sirc_config_t::div1
scg_async_clk_div_t scg_sirc_config_t::div2
scg_sirc_range_t scg_sirc_config_t::range
struct scg_firc_trim_config_t

Data Fields

scg_firc_trim_mode_t trimMode
 FIRC trim mode. More...
 
scg_firc_trim_src_t trimSrc
 Trim source. More...
 
scg_firc_trim_div_t trimDiv
 Trim predivided value for the system OSC. More...
 
uint8_t trimCoar
 Trim coarse value; Irrelevant if trimMode is kSCG_FircTrimUpdate. More...
 
uint8_t trimFine
 Trim fine value; Irrelevant if trimMode is kSCG_FircTrimUpdate. More...
 

Field Documentation

scg_firc_trim_mode_t scg_firc_trim_config_t::trimMode
scg_firc_trim_src_t scg_firc_trim_config_t::trimSrc
scg_firc_trim_div_t scg_firc_trim_config_t::trimDiv
uint8_t scg_firc_trim_config_t::trimCoar
uint8_t scg_firc_trim_config_t::trimFine
struct scg_firc_config_t

Data Fields

uint32_t enableMode
 Enable mode, OR'ed value of _scg_firc_enable_mode. More...
 
scg_async_clk_div_t div1
 FIRCDIV1 value. More...
 
scg_async_clk_div_t div2
 FIRCDIV2 value. More...
 
scg_firc_range_t range
 Fast IRC frequency range. More...
 
const scg_firc_trim_config_ttrimConfig
 Pointer to the FIRC trim configuration; set NULL to disable trim. More...
 

Field Documentation

uint32_t scg_firc_config_t::enableMode
scg_async_clk_div_t scg_firc_config_t::div1
scg_async_clk_div_t scg_firc_config_t::div2
scg_firc_range_t scg_firc_config_t::range
const scg_firc_trim_config_t* scg_firc_config_t::trimConfig
struct scg_lpfll_trim_config_t

Data Fields

scg_lpfll_trim_mode_t trimMode
 Trim mode. More...
 
scg_lpfll_lock_mode_t lockMode
 Lock mode; Irrelevant if the trimMode is kSCG_LpFllTrimNonUpdate. More...
 
scg_lpfll_trim_src_t trimSrc
 Trim source. More...
 
uint8_t trimDiv
 Trim predivideds value, which can be 0 ~ 31. More...
 
uint8_t trimValue
 Trim value; Irrelevant if trimMode is the kSCG_LpFllTrimUpdate. More...
 

Field Documentation

scg_lpfll_trim_mode_t scg_lpfll_trim_config_t::trimMode
scg_lpfll_lock_mode_t scg_lpfll_trim_config_t::lockMode
scg_lpfll_trim_src_t scg_lpfll_trim_config_t::trimSrc
uint8_t scg_lpfll_trim_config_t::trimDiv

[ Trim source frequency / (trimDiv + 1) ] must be 2 MHz or 32768 Hz.

uint8_t scg_lpfll_trim_config_t::trimValue
struct scg_lpfll_config_t

Data Fields

uint8_t enableMode
 Enable mode, OR'ed value of _scg_lpfll_enable_mode.
 
scg_async_clk_div_t div1
 LPFLLDIV1 value. More...
 
scg_async_clk_div_t div2
 LPFLLDIV2 value. More...
 
scg_lpfll_range_t range
 LPFLL frequency range. More...
 
const scg_lpfll_trim_config_ttrimConfig
 Trim configuration; set NULL to disable trim. More...
 

Field Documentation

scg_async_clk_div_t scg_lpfll_config_t::div1
scg_async_clk_div_t scg_lpfll_config_t::div2
scg_lpfll_range_t scg_lpfll_config_t::range
const scg_lpfll_trim_config_t* scg_lpfll_config_t::trimConfig

Macro Definition Documentation

#define FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL   0

When set to 0, peripheral drivers will enable clock in initialize function and disable clock in de-initialize function. When set to 1, peripheral driver will not control the clock, application could control the clock out of the driver.

Note
All drivers share this feature switcher. If it is set to 1, application should handle clock enable and disable for all drivers.
#define FSL_CLOCK_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
#define RTC_CLOCKS
Value:
{ \
kCLOCK_Rtc0 \
}
#define PORT_CLOCKS
Value:
{ \
kCLOCK_PortA, kCLOCK_PortB, kCLOCK_PortC, kCLOCK_PortD, kCLOCK_PortE \
}
#define LPI2C_CLOCKS
Value:
{ \
kCLOCK_Lpi2c0 \
}
#define TSI_CLOCKS
Value:
{ \
kCLOCK_Tsi0 \
}
#define LPUART_CLOCKS
Value:
{ \
kCLOCK_Lpuart0, kCLOCK_Lpuart1, kCLOCK_Lpuart2 \
}
#define LPTMR_CLOCKS
Value:
{ \
kCLOCK_Lptmr0 \
}
#define ADC12_CLOCKS
Value:
{ \
kCLOCK_Adc0 \
}
#define LPSPI_CLOCKS
Value:
{ \
kCLOCK_Lpspi0 \
}
#define LPIT_CLOCKS
Value:
{ \
kCLOCK_Lpit0 \
}
#define CRC_CLOCKS
Value:
{ \
kCLOCK_Crc0 \
}
#define CMP_CLOCKS
Value:
{ \
kCLOCK_Cmp0 \
}
#define FLASH_CLOCKS
Value:
{ \
kCLOCK_Flash0 \
}
#define EWM_CLOCKS
Value:
{ \
kCLOCK_Ewm0 \
}
#define FTM_CLOCKS
Value:
{ \
kCLOCK_Ftm0, kCLOCK_Ftm1 \
}
#define PDB_CLOCKS
Value:
{ \
kCLOCK_Pdb0 \
}
#define PWT_CLOCKS
Value:
{ \
kCLOCK_Pwt0 \
}
#define MSCAN_CLOCKS
Value:
{ \
kCLOCK_Mscan0 \
}
#define CLOCK_GetOsc0ErClkFreq   CLOCK_GetErClkFreq

Enumeration Type Documentation

Enumerator
kCLOCK_CoreSysClk 

Core/system clock.

kCLOCK_BusClk 

Bus clock.

kCLOCK_FlashClk 

Flash clock.

kCLOCK_ScgSysOscClk 

SCG system OSC clock.

(SYSOSC)

kCLOCK_ScgSircClk 

SCG SIRC clock.

kCLOCK_ScgFircClk 

SCG FIRC clock.

kCLOCK_ScgLpFllClk 

SCG low power FLL clock.

(LPFLL)

kCLOCK_ScgSysOscAsyncDiv2Clk 

SOSCDIV2_CLK.

kCLOCK_ScgSircAsyncDiv2Clk 

SIRCDIV2_CLK.

kCLOCK_ScgFircAsyncDiv2Clk 

FIRCDIV2_CLK.

kCLOCK_ScgLpFllAsyncDiv2Clk 

LPFLLDIV2_CLK.

kCLOCK_LpoClk 

LPO clock.

kCLOCK_ErClk 

ERCLK.

The external reference clock from SCG.

Enumerator
kCLOCK_IpSrcNoneOrExt 

Clock is off or external clock is used.

kCLOCK_IpSrcSysOscAsync 

System Oscillator async clock.

kCLOCK_IpSrcSircAsync 

Slow IRC async clock.

kCLOCK_IpSrcFircAsync 

Fast IRC async clock.

kCLOCK_IpSrcLpFllAsync 

LPFLL async clock.

It is defined as the corresponding register address.

Enumerator
kStatus_SCG_Busy 

Clock is busy.

kStatus_SCG_InvalidSrc 

Invalid source.

Enumerator
kSCG_SysClkSlow 

System slow clock.

kSCG_SysClkCore 

Core clock.

Enumerator
kSCG_SysClkSrcSysOsc 

System OSC.

kSCG_SysClkSrcSirc 

Slow IRC.

kSCG_SysClkSrcFirc 

Fast IRC.

kSCG_SysClkSrcLpFll 

Low power FLL.

Enumerator
kSCG_SysClkDivBy1 

Divided by 1.

kSCG_SysClkDivBy2 

Divided by 2.

kSCG_SysClkDivBy3 

Divided by 3.

kSCG_SysClkDivBy4 

Divided by 4.

kSCG_SysClkDivBy5 

Divided by 5.

kSCG_SysClkDivBy6 

Divided by 6.

kSCG_SysClkDivBy7 

Divided by 7.

kSCG_SysClkDivBy8 

Divided by 8.

kSCG_SysClkDivBy9 

Divided by 9.

kSCG_SysClkDivBy10 

Divided by 10.

kSCG_SysClkDivBy11 

Divided by 11.

kSCG_SysClkDivBy12 

Divided by 12.

kSCG_SysClkDivBy13 

Divided by 13.

kSCG_SysClkDivBy14 

Divided by 14.

kSCG_SysClkDivBy15 

Divided by 15.

kSCG_SysClkDivBy16 

Divided by 16.

Enumerator
kClockClkoutSelScgSlow 

SCG slow clock.

kClockClkoutSelSysOsc 

System OSC.

kClockClkoutSelSirc 

Slow IRC.

kClockClkoutSelFirc 

Fast IRC.

kClockClkoutSelLpFll 

Low power FLL.

Enumerator
kSCG_AsyncDiv1Clk 

The async clock by DIV1, e.g.

SOSCDIV1_CLK, SIRCDIV1_CLK.

kSCG_AsyncDiv2Clk 

The async clock by DIV2, e.g.

SOSCDIV2_CLK, SIRCDIV2_CLK.

Enumerator
kSCG_AsyncClkDisable 

Clock output is disabled.

kSCG_AsyncClkDivBy1 

Divided by 1.

kSCG_AsyncClkDivBy2 

Divided by 2.

kSCG_AsyncClkDivBy4 

Divided by 4.

kSCG_AsyncClkDivBy8 

Divided by 8.

kSCG_AsyncClkDivBy16 

Divided by 16.

kSCG_AsyncClkDivBy32 

Divided by 32.

kSCG_AsyncClkDivBy64 

Divided by 64.

Enumerator
kSCG_SysOscMonitorDisable 

Monitor disabled.

kSCG_SysOscMonitorInt 

Interrupt when the system OSC error is detected.

kSCG_SysOscMonitorReset 

Reset when the system OSC error is detected.

Enumerator
kSCG_SysOscModeExt 

Use external clock.

kSCG_SysOscModeOscLowPower 

Oscillator low power.

kSCG_SysOscModeOscHighGain 

Oscillator high gain.

Enumerator
kSCG_SysOscEnable 

Enable OSC clock.

kSCG_SysOscEnableInStop 

Enable OSC in stop mode.

kSCG_SysOscEnableInLowPower 

Enable OSC in low power mode.

kSCG_SysOscEnableErClk 

Enable OSCERCLK.

Enumerator
kSCG_SircRangeLow 

Slow IRC low range clock (2 MHz, 4 MHz for i.MX 7 ULP).

kSCG_SircRangeHigh 

Slow IRC high range clock (8 MHz, 16 MHz for i.MX 7 ULP).

Enumerator
kSCG_SircEnable 

Enable SIRC clock.

kSCG_SircEnableInStop 

Enable SIRC in stop mode.

kSCG_SircEnableInLowPower 

Enable SIRC in low power mode.

Enumerator
kSCG_FircTrimNonUpdate 

FIRC trim enable but not enable trim value update.

In this mode, the trim value is fixed to the initialized value which is defined by trimCoar and trimFine in configure structure scg_firc_trim_config_t.

kSCG_FircTrimUpdate 

FIRC trim enable and trim value update enable.

In this mode, the trim value is auto update.

Enumerator
kSCG_FircTrimDivBy1 

Divided by 1.

kSCG_FircTrimDivBy128 

Divided by 128.

kSCG_FircTrimDivBy256 

Divided by 256.

kSCG_FircTrimDivBy512 

Divided by 512.

kSCG_FircTrimDivBy1024 

Divided by 1024.

kSCG_FircTrimDivBy2048 

Divided by 2048.

Enumerator
kSCG_FircTrimSrcSysOsc 

System OSC.

Enumerator
kSCG_FircRange48M 

Fast IRC is trimmed to 48 MHz.

kSCG_FircRange52M 

Fast IRC is trimmed to 52 MHz.

kSCG_FircRange56M 

Fast IRC is trimmed to 56 MHz.

kSCG_FircRange60M 

Fast IRC is trimmed to 60 MHz.

Enumerator
kSCG_FircEnable 

Enable FIRC clock.

kSCG_FircEnableInStop 

Enable FIRC in stop mode.

kSCG_FircEnableInLowPower 

Enable FIRC in low power mode.

kSCG_FircDisableRegulator 

Disable regulator.

Enumerator
kSCG_LpFllEnable 

Enable LPFLL clock.

Enumerator
kSCG_LpFllRange48M 

LPFLL is trimmed to 48MHz.

kSCG_LpFllRange72M 

LPFLL is trimmed to 72MHz.

kSCG_LpFllRange96M 

LPFLL is trimmed to 96MHz.

kSCG_LpFllRange120M 

LPFLL is trimmed to 120MHz.

Enumerator
kSCG_LpFllTrimNonUpdate 

LPFLL trim is enabled but the trim value update is not enabled.

In this mode, the trim value is fixed to the initialized value, which is defined by the trimValue in the structure scg_lpfll_trim_config_t.

kSCG_LpFllTrimUpdate 

FIRC trim is enabled and trim value update is enabled.

In this mode, the trim value is automatically updated.

Enumerator
kSCG_LpFllTrimSrcSirc 

SIRC.

kSCG_LpFllTrimSrcFirc 

FIRC.

kSCG_LpFllTrimSrcSysOsc 

System OSC.

kSCG_LpFllTrimSrcRtcOsc 

RTC OSC (32.768 kHz).

Enumerator
kSCG_LpFllLock1Lsb 

Lock with 1 LSB.

kSCG_LpFllLock2Lsb 

Lock with 2 LSB.

Function Documentation

static void CLOCK_EnableClock ( clock_ip_name_t  name)
inlinestatic
Parameters
nameWhich clock to enable, see clock_ip_name_t.
static void CLOCK_DisableClock ( clock_ip_name_t  name)
inlinestatic
Parameters
nameWhich clock to disable, see clock_ip_name_t.
static void CLOCK_SetIpSrc ( clock_ip_name_t  name,
clock_ip_src_t  src 
)
inlinestatic

Set the clock source for specific IP, not all modules need to set the clock source, should only use this function for the modules need source setting.

Parameters
nameWhich peripheral to check, see clock_ip_name_t.
srcClock source to set.
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.

Parameters
clockNameClock 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_GetBusClkFreq ( void  )
Returns
Clock frequency in Hz.
uint32_t CLOCK_GetFlashClkFreq ( void  )
Returns
Clock frequency in Hz.
uint32_t CLOCK_GetErClkFreq ( void  )
Returns
Clock frequency in Hz.
uint32_t CLOCK_GetIpFreq ( clock_ip_name_t  name)

This function gets the IP module clock frequency based on PCC registers. It is only used for the IP modules which could select clock source by PCC[PCS].

Parameters
nameWhich peripheral to get, see clock_ip_name_t.
Returns
Clock frequency value in hertz
uint32_t CLOCK_GetSysClkFreq ( scg_sys_clk_t  type)

This function gets the SCG system clock frequency. These clocks are used for core, platform, external, and bus clock domains.

Parameters
typeWhich type of clock to get, core clock or slow clock.
Returns
Clock frequency.
static void CLOCK_SetVlprModeSysClkConfig ( const scg_sys_clk_config_t config)
inlinestatic

This function sets the system clock configuration for VLPR mode.

Parameters
configPointer to the configuration.
static void CLOCK_SetRunModeSysClkConfig ( const scg_sys_clk_config_t config)
inlinestatic

This function sets the system clock configuration for RUN mode.

Parameters
configPointer to the configuration.
static void CLOCK_GetCurSysClkConfig ( scg_sys_clk_config_t config)
inlinestatic

This function gets the system configuration in the current power mode.

Parameters
configPointer to the configuration.
static void CLOCK_SetClkOutSel ( clock_clkout_src_t  setting)
inlinestatic

This function sets the clock out selection (CLKOUTSEL).

Parameters
settingThe selection to set.
Returns
The current clock out selection.
status_t CLOCK_InitSysOsc ( const scg_sosc_config_t config)

This function enables the SCG system OSC clock according to the configuration.

Parameters
configPointer to the configuration structure.
Return values
kStatus_SuccessSystem OSC is initialized.
kStatus_SCG_BusySystem OSC has been enabled and is used by the system clock.
kStatus_ReadOnlySystem OSC control register is locked.
Note
This function can't detect whether the system OSC has been enabled and used by an IP.
status_t CLOCK_DeinitSysOsc ( void  )

This function disables the SCG system OSC clock.

Return values
kStatus_SuccessSystem OSC is deinitialized.
kStatus_SCG_BusySystem OSC is used by the system clock.
kStatus_ReadOnlySystem OSC control register is locked.
Note
This function can't detect whether the system OSC is used by an IP.
static void CLOCK_SetSysOscAsyncClkDiv ( scg_async_clk_t  asyncClk,
scg_async_clk_div_t  divider 
)
inlinestatic
Parameters
asyncClkWhich asynchronous clock to configure.
dividerThe divider value to set.
Note
There might be glitch when changing the asynchronous divider, so make sure the asynchronous clock is not used while changing divider.
uint32_t CLOCK_GetSysOscFreq ( void  )
Returns
Clock frequency; If the clock is invalid, returns 0.
uint32_t CLOCK_GetSysOscAsyncFreq ( scg_async_clk_t  type)
Parameters
typeThe asynchronous clock type.
Returns
Clock frequency; If the clock is invalid, returns 0.
static bool CLOCK_IsSysOscErr ( void  )
inlinestatic
Returns
True if the error occurs, false if not.
static void CLOCK_SetSysOscMonitorMode ( scg_sosc_monitor_mode_t  mode)
inlinestatic

This function sets the system OSC monitor mode. The mode can be disabled, it can generate an interrupt when the error is disabled, or reset when the error is detected.

Parameters
modeMonitor mode to set.
static bool CLOCK_IsSysOscValid ( void  )
inlinestatic
Returns
True if clock is valid, false if not.
status_t CLOCK_InitSirc ( const scg_sirc_config_t config)

This function enables the SCG slow IRC clock according to the configuration.

Parameters
configPointer to the configuration structure.
Return values
kStatus_SuccessSIRC is initialized.
kStatus_SCG_BusySIRC has been enabled and is used by system clock.
kStatus_ReadOnlySIRC control register is locked.
Note
This function can't detect whether the system OSC has been enabled and used by an IP.
status_t CLOCK_DeinitSirc ( void  )

This function disables the SCG slow IRC.

Return values
kStatus_SuccessSIRC is deinitialized.
kStatus_SCG_BusySIRC is used by system clock.
kStatus_ReadOnlySIRC control register is locked.
Note
This function can't detect whether the SIRC is used by an IP.
static void CLOCK_SetSircAsyncClkDiv ( scg_async_clk_t  asyncClk,
scg_async_clk_div_t  divider 
)
inlinestatic
Parameters
asyncClkWhich asynchronous clock to configure.
dividerThe divider value to set.
Note
There might be glitch when changing the asynchronous divider, so make sure the asynchronous clock is not used while changing divider.
uint32_t CLOCK_GetSircFreq ( void  )
Returns
Clock frequency; If the clock is invalid, returns 0.
uint32_t CLOCK_GetSircAsyncFreq ( scg_async_clk_t  type)
Parameters
typeThe asynchronous clock type.
Returns
Clock frequency; If the clock is invalid, returns 0.
static bool CLOCK_IsSircValid ( void  )
inlinestatic
Returns
True if clock is valid, false if not.
status_t CLOCK_InitFirc ( const scg_firc_config_t config)

This function enables the SCG fast IRC clock according to the configuration.

Parameters
configPointer to the configuration structure.
Return values
kStatus_SuccessFIRC is initialized.
kStatus_SCG_BusyFIRC has been enabled and is used by the system clock.
kStatus_ReadOnlyFIRC control register is locked.
Note
This function can't detect whether the FIRC has been enabled and used by an IP.
status_t CLOCK_DeinitFirc ( void  )

This function disables the SCG fast IRC.

Return values
kStatus_SuccessFIRC is deinitialized.
kStatus_SCG_BusyFIRC is used by the system clock.
kStatus_ReadOnlyFIRC control register is locked.
Note
This function can't detect whether the FIRC is used by an IP.
static void CLOCK_SetFircAsyncClkDiv ( scg_async_clk_t  asyncClk,
scg_async_clk_div_t  divider 
)
inlinestatic
Parameters
asyncClkWhich asynchronous clock to configure.
dividerThe divider value to set.
Note
There might be glitch when changing the asynchronous divider, so make sure the asynchronous clock is not used while changing divider.
uint32_t CLOCK_GetFircFreq ( void  )
Returns
Clock frequency; If the clock is invalid, returns 0.
uint32_t CLOCK_GetFircAsyncFreq ( scg_async_clk_t  type)
Parameters
typeThe asynchronous clock type.
Returns
Clock frequency; If the clock is invalid, returns 0.
static bool CLOCK_IsFircErr ( void  )
inlinestatic
Returns
True if the error occurs, false if not.
static bool CLOCK_IsFircValid ( void  )
inlinestatic
Returns
True if clock is valid, false if not.
status_t CLOCK_InitLpFll ( const scg_lpfll_config_t config)

This function enables the SCG LPFLL clock according to the configuration.

Parameters
configPointer to the configuration structure.
Return values
kStatus_SuccessLPFLL is initialized.
kStatus_SCG_BusyLPFLL has been enabled and is used by the system clock.
kStatus_ReadOnlyLPFLL control register is locked.
Note
This function can't detect whether the LPFLL has been enabled and used by an IP.
status_t CLOCK_DeinitLpFll ( void  )

This function disables the SCG LPFLL.

Return values
kStatus_SuccessLPFLL is deinitialized.
kStatus_SCG_BusyLPFLL is used by the system clock.
kStatus_ReadOnlyLPFLL control register is locked.
Note
This function can't detect whether the LPFLL is used by an IP.
static void CLOCK_SetLpFllAsyncClkDiv ( scg_async_clk_t  asyncClk,
scg_async_clk_div_t  divider 
)
inlinestatic
Parameters
asyncClkWhich asynchronous clock to configure.
dividerThe divider value to set.
Note
There might be glitch when changing the asynchronous divider, so make sure the asynchronous clock is not used while changing divider.
uint32_t CLOCK_GetLpFllFreq ( void  )
Returns
Clock frequency in Hz; If the clock is invalid, returns 0.
uint32_t CLOCK_GetLpFllAsyncFreq ( scg_async_clk_t  type)
Parameters
typeThe asynchronous clock type.
Returns
Clock frequency in Hz; If the clock is invalid, returns 0.
static bool CLOCK_IsLpFllValid ( void  )
inlinestatic
Returns
True if the clock is valid, false if not.
static void CLOCK_SetXtal0Freq ( uint32_t  freq)
inlinestatic
Parameters
freqThe XTAL0/EXTAL0 input clock frequency in Hz.

Variable Documentation

volatile uint32_t g_xtal0Freq

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

* CLOCK_InitSysOsc(...); // Set up the OSC0/SYSOSC
* CLOCK_SetXtal0Freq(80000000); // Set the XTAL0 value in the clock driver.
*

This is important for the multicore platforms where only one core needs to set up the OSC0/SYSOSC using CLOCK_InitSysOsc. All other cores need to call the CLOCK_SetXtal0Freq to get a valid clock frequency.