| 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
Modules
Clock Driver

## Overview

The KSDK provides APIs for Kinetis devices clock operation.

# Get frequency

There is a centralized function CLOCK_GetFreq to get different types of clock frequency by passing in clock name, for example, pass in kCLOCK_CoreSysClk to get core clock, pass in kCLOCK_BusClk to get bus clock. Beside, there are also separate functions to get frequency, for example, use CLOCK_GetCoreSysClkFreq to get core clock frequency, use CLOCK_GetBusClkFreq to get bus clock frequency, use these separate functions could reduce image size.

# External clock frequency

The external clock EXTAL0/EXTAL1/EXTAL32 are decided by board level design. Clock driver uses variables g_xtal0Freq/g_xtal1Freq/g_xtal32Freq to save these clock frequency. Correspondingly, the APIs CLOCK_SetXtal0Freq, CLOCK_SetXtal1Freq and CLOCK_SetXtal32Freq are used to set these variables.
Upper layer must set these values correctly, for example, after OSC0(SYSOSC) is initialized using CLOCK_InitOsc0 or CLOCK_InitSysOsc, upper layer should call CLOCK_SetXtal0Freq too. Otherwise, the clock frequency get functions may not get valid value. This is useful for multi-core platforms, only one core calls CLOCK_InitOsc0 to initialize OSC0, other cores only need to call CLOCK_SetXtal0Freq.

The next section shows the MCG_Lite based APIs, the MCG based APIs are similar, will not explain in this document.

## Modules
| Multipurpose Clock Generator Lite (MCGLITE)