The friendly Operating System for the Internet of Things

Implementation of the Kinetis Multipurpose Clock Generator (MCG) driver. More...

Detailed Description

Please add mcg.h in cpu conf.h and MCG configuration to periph_conf.h

MCG neighbor modes matrix:

x FEI FEE FBI FBE BLPI BLPE PBE PEE
PEE 0 0 0 0 0 0 1 0
PBE 0 0 0 1 0 1 0 1
BLPE 0 0 0 1 0 0 1 0
BLPI 0 0 1 0 0 0 0 0
FBE 1 1 1 0 0 1 1 0
FBI 1 1 0 1 1 0 0 0
FEE 1 0 1 1 0 0 0 0
FEI 1 1 1 1 0 0 0 0

Each neighbor mode can be selected directly. Further, the paths between the following modes are defined:

MCG Configuration Examples (for periph_conf.h)

Example for FEI Mode (MCGOUTCLK = 20MHz ... 25MHz):

#define KINETIS_MCG_USE_ERC               0
#define KINETIS_MCG_DCO_RANGE             (24000000U)

Example for FEE Mode, 32768Hz Crystal, (MCGOUTCLK = 24MHz):

#define KINETIS_MCG_USE_ERC               1
#define KINETIS_MCG_USE_PLL               0
#define KINETIS_MCG_DCO_RANGE             (24000000U)
#define KINETIS_MCG_ERC_OSCILLATOR        1
#define KINETIS_MCG_ERC_FRDIV             0
#define KINETIS_MCG_ERC_RANGE             0
#define KINETIS_MCG_ERC_FREQ              (32768U)

Example for FEE Mode, external 4MHz reference ( $MCGOUTCLK = \frac{ERC_{\mathrm{freq}}\cdot FFL_{\mathrm{Factor}}}{FRDIV} = \frac{4\,\mathrm{MHz}\cdot 732}{128} = 22.875\,\mathrm{MHz}$):

#define KINETIS_MCG_USE_ERC               1
#define KINETIS_MCG_USE_PLL               0
#define KINETIS_MCG_DCO_RANGE             (24000000U)
#define KINETIS_MCG_ERC_OSCILLATOR        0
#define KINETIS_MCG_ERC_FRDIV             2
#define KINETIS_MCG_ERC_RANGE             1
#define KINETIS_MCG_ERC_FREQ              (4000000U)

Example for PEE Mode, external 4MHz reference ( $MCGOUTCLK = \frac{ERC_{\mathrm{freq}}\cdot VDIV0}{PRDIV} = \frac{4\,\mathrm{MHz}\cdot 24}{2} = 48\,\mathrm{MHz}$):

#define KINETIS_MCG_USE_ERC               1
#define KINETIS_MCG_USE_PLL               1
#define KINETIS_MCG_DCO_RANGE             (24000000U)
#define KINETIS_MCG_ERC_OSCILLATOR        0
#define KINETIS_MCG_ERC_FRDIV             2
#define KINETIS_MCG_ERC_RANGE             1
#define KINETIS_MCG_ERC_FREQ              (4000000U)
#define KINETIS_MCG_PLL_PRDIV             1
#define KINETIS_MCG_PLL_VDIV0             0
#define KINETIS_MCG_PLL_FREQ              (48000000U)

The desired mode can be selected in cpu.c:cpu_clock_init() with kinetis_mcg_set_mode(KINETIS_MCG_PEE);

Files

file  mcg.h
 Interface definition for the Kinetis MCG driver.