MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
The clock module is used to help software to configure the MCU OCCS and relevant field in SIM module, to provide proper clock to MCU core and its peripherals.
Driver Overview | |
Driver Change Log | |
Current CLOCK driver version is 2.0.0. | |
Data Structures | |
struct | clock_protection_config_t |
Clock register protection configuration. More... | |
struct | clock_output_config_t |
Clock output configuration. More... | |
struct | clock_config_t |
mcu clock configuration structure. More... | |
Macros | |
#define | FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL 0 |
Configure whether driver controls clock. More... | |
#define | SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY (100000000UL) |
Definition for delay API in clock driver, users can redefine it to the real application. More... | |
#define | GPIO_CLOCKS |
Clock ip name array for GPIO. More... | |
#define | TMR_CLOCKS |
Clock ip name array for quad timer. More... | |
#define | FLEXCAN_CLOCKS |
Clock ip name array for FLEXCAN. More... | |
#define | I2C_CLOCKS |
Clock ip name array for I2C. More... | |
#define | QSPI_CLOCKS |
Clock ip name array for queued SPI. More... | |
#define | QSCI_CLOCKS |
Clock ip name array for queued SCI. More... | |
#define | DAC_CLOCKS |
Clock ip name array for DAC. More... | |
#define | PIT_CLOCKS |
Clock ip name array for PIT. More... | |
#define | CRC_CLOCKS |
Clock ip name array for CRC. More... | |
#define | CADC_CLOCKS |
Clock ip name array for cyclic ADC. More... | |
#define | CMP_CLOCKS |
Clock ip name array for CMP. More... | |
#define | PWM_CLOCKS |
Clock ip name array for PWM. More... | |
#define | USB_CLOCKS |
Clock ip name array for USB. More... | |
#define | ROM_CLOCKS |
Clock ip name array for ROM. More... | |
#define | EDMA_CLOCKS |
Clock ip name array for EDMA. More... | |
#define | EWM_CLOCKS |
Clock ip name array for EWM. More... | |
#define | XBARA_CLOCKS |
Clock ip name array for XBARA. More... | |
Functions | |
static void | CLOCK_EnableClock (clock_ip_name_t eIpClkName) |
Enable IPs clock. More... | |
static void | CLOCK_DisableClock (clock_ip_name_t eIpClkName) |
Disable IPs clock. More... | |
static void | CLOCK_EnableClockInStopMode (clock_ip_name_t eIpClkName) |
Enable IPs clock in STOP mode. More... | |
static void | CLOCK_DisableClockInStopMode (clock_ip_name_t eIpClkName) |
Disable IPs clock in STOP mode. More... | |
static void | CLOCK_ConfigQsciClockSrc (clock_ip_name_t eQsciClkName, clock_ip_clk_src_t eClkSrc) |
Configure QSCI clock source. More... | |
static void | CLOCK_ConfigI2cFilterClockSrc (clock_ip_name_t eI2cClkName, clock_ip_clk_src_t eClkSrc) |
Configure I2C filter clock source. More... | |
static void | CLOCK_SetSlowIrcTrim (uint16_t u16Trim) |
Set trim value to 200K slow internal RC oscillator. More... | |
static bool | CLOCK_GetCrystalOscFailureStatus (void) |
Get crystal oscillator failure status. More... | |
static void | CLOCK_SetPllLossofRefererntTripPoint (uint8_t u8Trip) |
Set PLL loss of reference trip point. More... | |
static void | CLOCK_ClearPLLMonitorFlag (clock_pll_monitor_type_t eType) |
Clear PLL monitor flag. More... | |
uint32_t | CLOCK_GetFreq (clock_name_t eClkName) |
Get system-level clock frequency. More... | |
uint32_t | CLOCK_GetIpClkSrcFreq (clock_ip_name_t eIpClkName) |
Get IP clock frequency. More... | |
void | CLOCK_SetClkin0Freq (uint32_t u32Freq) |
Set Clock IN 0 frequency. More... | |
void | CLOCK_SetClkin1Freq (uint32_t u32Freq) |
Set Clock IN 1 frequency. More... | |
void | CLOCK_SetXtalFreq (uint32_t u32Freq) |
Set crystal oscillator frequency. More... | |
void | CLOCK_SetProtectionConfig (clock_protection_config_t *psConfig) |
Config clock register access protection mode. More... | |
void | CLOCK_SetOutputClockConfig (clock_output_config_t *psConfig) |
Config output clock. More... | |
void | CLOCK_SetClkConfig (clock_config_t *psConfig) |
Config mcu operation clock. More... | |
void | CLOCK_EnableUsbfs0Clock (void) |
Enable USB FS clock. | |
uint32_t | CLOCK_EvaluateExtClkFreq (void) |
Evaluate external clock frequency and return its frequency in Hz. More... | |
void | CLOCK_EnablePLLMonitorInterrupt (clock_pll_monitor_type_t eType, bool bEnable) |
Enable/Disable PLL monitor interrupt. More... | |
Driver version | |
#define | FSL_CLOCK_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) |
CLOCK driver version 2.0.1. More... | |
struct clock_protection_config_t |
Data Fields | |
clock_protection_t | eFrqEP |
FRQEP bit field in OCCS PROT register, protect COD & ZSRC. More... | |
clock_protection_t | eOscEP |
OSCEP bit field in OCCS PROT register, protect OSCTL1, OSCTL2, PRECS. More... | |
clock_protection_t | ePllEP |
PLLEP bit field in OCCS PROT register, protect PLLDP, LOCIE, LORTP, PLLDB bitfield. More... | |
clock_protection_t clock_protection_config_t::eFrqEP |
clock_protection_t clock_protection_config_t::eOscEP |
clock_protection_t clock_protection_config_t::ePllEP |
struct clock_output_config_t |
Data Fields | |
bool | bClkOut0En |
Clock output 0 enable, CLKDIS0 bit field in SIM CLKOUT register. | |
bool | bClkOut1En |
Clock output 1 enable, CLKDIS1 bit field in SIM CLKOUT register. | |
clock_output_clk_src_t | eClkOut0Src |
Clock output 0 clock source, CLKOSEL0 bit field in SIM CLKOUT register. | |
clock_output_clk_src_t | eClkOut1Src |
Clock output 1 clock source, CLKOSEL1 bit field in SIM CLKOUT register. | |
clock_output_clk_div_t | eClkDiv |
Clock output divider, CLKODIV bit field in SIM CLKOUT register ,it apply to clkout0 & clkout1. | |
struct clock_config_t |
This is the key configuration structure of clock driver, which define the system clock behavior. The function CLOCK_SetClkConfig deploy this configuration structure onto SOC.
Data Fields | |
bool | bCrystalOscEnable |
Crystal oscillator enable, COPD bit field in OCCS OSCTL2 register. | |
bool | bFircEnable |
Fast internal RC oscillator enable, IRC48M_EN bit field in SIM MISC0 register. | |
bool | bSircEnable |
Slow internal RC oscillator enable, ROPD200K bit field in OCCS OSCTL2 register. | |
bool | bPllEnable |
PLL enable, PLLPD bit field in OCCS CTRL register. | |
bool | bCrystalOscMonitorEnable |
Crystal oscillator monitor enable, MON_ENABLE bit field in OCCS OSCTL2 register. | |
clock_crystal_osc_mode_t | eCrystalOscMode |
Crystal oscillator mode, COHL bit field in OCCS OSCTL1 register. | |
clock_ext_clk_src_t | eExtClkSrc |
External clock source, EXT_SEL bit field in OCCS OSCTL1 register. | |
clock_ext_clkin_sel_t | eClkInSel |
Clock IN selection(0 or 1), CLKINSEL bit field in SIM MISC0 register. | |
clock_mstr_osc_clk_src_t | eMstrOscClkSrc |
Master oscillator selection, PRECS bit field in OCCS CTRL register. More... | |
clock_mstr_2x_clk_src_t | eMstr2xClkSrc |
Master 2x clock selection, ZSRC bit field in OCCS CTRL register. | |
clock_postscale_t | eMstr2xClkPostScale |
Master 2x clock post scale, COD bit field in OCCS DIVBY register. | |
uint32_t | u32PllClkFreq |
Required PLL output frequency before divide 2. | |
clock_mstr_osc_clk_src_t clock_config_t::eMstrOscClkSrc |
When selected kCLOCK_MstrOscClkSrcExt, make sure corresponding pins(crystal osc or clkin pin) has been configured.
#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.
#define FSL_CLOCK_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) |
#define SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY (100000000UL) |
#define GPIO_CLOCKS |
#define TMR_CLOCKS |
#define FLEXCAN_CLOCKS |
#define I2C_CLOCKS |
#define QSPI_CLOCKS |
#define QSCI_CLOCKS |
#define DAC_CLOCKS |
#define PIT_CLOCKS |
#define CRC_CLOCKS |
#define CADC_CLOCKS |
#define CMP_CLOCKS |
#define PWM_CLOCKS |
#define USB_CLOCKS |
#define ROM_CLOCKS |
#define EDMA_CLOCKS |
#define EWM_CLOCKS |
#define XBARA_CLOCKS |
enum clock_ip_name_t |
enum clock_name_t |
enum clock_ext_clk_src_t |
enum clock_protection_t |
enum clock_ip_clk_src_t |
enum clock_postscale_t |
|
inlinestatic |
eIpClkName | IP clock name. |
|
inlinestatic |
eIpClkName | IP clock name. |
|
inlinestatic |
eIpClkName | IP clock name. |
|
inlinestatic |
eIpClkName | IP clock name. |
|
inlinestatic |
QSCI clock could be bus or bus_2x clock. Default is bus clock.
eQsciClkName | IP(only QSCI is valid) clock name. |
eClkSrc | Clock source. |
|
inlinestatic |
I2C filter clock could be bus or bus_2x clock. Default is bus clock.
eI2cClkName | IP(only I2C is valid) clock name. |
eClkSrc | Clock source. |
|
inlinestatic |
The factory trim value is loaded during reset. User may call this function to fine tune the 200K IRC oscillator.
u16Trim | Slow internal RC oscillator trim value. |
|
inlinestatic |
This function should be called only when crystal osc is on and its monitor(MON_ENABLE in OSCTL2 register) is enabled.
|
inlinestatic |
The trip point default value is 2.
u8Trip | Trip point for loss of reference. |
|
inlinestatic |
eType | PLL monitor type. |
uint32_t CLOCK_GetFreq | ( | clock_name_t | eClkName | ) |
eClkName | System-level clock name. |
uint32_t CLOCK_GetIpClkSrcFreq | ( | clock_ip_name_t | eIpClkName | ) |
eIpClkName | IP clock name. |
void CLOCK_SetClkin0Freq | ( | uint32_t | u32Freq | ) |
It is a must to call this function in advance if system is operated by clkin0.
u32Freq | Clock IN 0 frequency in Hz. |
void CLOCK_SetClkin1Freq | ( | uint32_t | u32Freq | ) |
It is a must to call this function in advance if system is operated by clkin1.
u32Freq | Clock IN 1 frequency in Hz. |
void CLOCK_SetXtalFreq | ( | uint32_t | u32Freq | ) |
It is a must to call this function in advance if system is operated by crystal oscillator.
u32Freq | Crystal oscillator frequency in Hz. |
void CLOCK_SetProtectionConfig | ( | clock_protection_config_t * | psConfig | ) |
psConfig | Pointer for protection configuration. |
void CLOCK_SetOutputClockConfig | ( | clock_output_config_t * | psConfig | ) |
psConfig | Pointer for clock output configuration. |
void CLOCK_SetClkConfig | ( | clock_config_t * | psConfig | ) |
psConfig | Pointer for clock configuration. |
uint32_t CLOCK_EvaluateExtClkFreq | ( | void | ) |
This function should be called only when internal FIRC(48M) is on. The evaluated result accuracy depends on:
For example, for namely 8M external clock, evaluated result may be range in 8M+/-5%.
void CLOCK_EnablePLLMonitorInterrupt | ( | clock_pll_monitor_type_t | eType, |
bool | bEnable | ||
) |
This function should be called only when PLL is on and its reference clock is external clock. This function is for safety purpose when external clock is lost due to HW failure. The normal flow to call this function:
eType | PLL monitor type. |
bEnable | Enable or disable. |