![]() |
Kinetis SDK v.1.2 API Reference Manual
Rev. 0
Freescale Semiconductor, Inc.
|
This section describes the programming interface of the SCG HAL driver. The SCG HAL driver configures the SCG (System Clock Generator). It handles calibration, initialization, and configuration of SCG module.
SCG driver provides three kinds of APIs:
MCU system clock configuration includes clock source and dividers. There are dedicated control registers for RUN mode, VLPR mode and HSRUN mode. When MCU switches to new power mode, the configuration for corresponding mode will be used.
SCG driver provides the APIs to set and get this configure registers, for example, to get the system clock configuration of RUN mode, please use the function CLOCK_HAL_GetSystemClockConfigInRun(), to set the system clock configuration of VLPR mode, please use the function CLOCK_HAL_SetSystemClockConfigInVlpr().
Besides these APIs, SCG HAL driver also provides CLOCK_HAL_GetSystemClockFreq() to get the system clock output frequency.
For SCG CLKOUT, SCG HAL driver provides CLOCK_HAL_GetClkOutSel() and CLOCK_HAL_SetClkOutSel() to get and set configuration.
SCG has four clock sources, system OSC, system PLL, fast IRC and slow IRC. For each clock source, SCG driver provides such APIs:
There is an example shows how to setup the clock source base on SCG HAL APIs.
Because some configurations of the clock source could only be changed when the clock source is disabled, so the function CLOCK_HAL_InitXxx
will disable the clock source, then re-configure it and enable it. As a result, before CLOCK_HAL_InitXxx
, please make sure the clock source is not used.