Kinetis SDK v.1.3 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
OSC HAL driver

Overview

The section describes the programming interface of the OSC HAL driver. The OSC module is a crystal oscillator. The module and the external crystal or resonator generate a reference clock for the MCU.
The OSC HAL driver provides APIs to:

OSCERCLK Configure APIs

To enable/disable OSCERCLK, use the functions OSC_HAL_SetExternalRefClkCmd() and OSC_HAL_SetExternalRefClkInStopModeCmd(). These functions configure the OSCERCLK enabling or disabling in normal mode or stop mode.
The function OSC_HAL_SetExternalRefClkDiv() configures the OSCERCLK divider.

Capacitor Load Configure APIs

To configure capacitor load, use the function OSC_HAL_SetCapacitor and pass the capacitor load as parameter. Example:

#include "fsl_osc_hal.h"
// To enable only 2 pF and 8 pF capacitor load, do this:

Files

file  fsl_osc_hal.h
 

Enumerations

enum  osc_capacitor_config_t {
  kOscCapacitor2p = OSC_CR_SC2P_MASK,
  kOscCapacitor4p = OSC_CR_SC4P_MASK,
  kOscCapacitor8p = OSC_CR_SC8P_MASK,
  kOscCapacitor16p = OSC_CR_SC16P_MASK
}
 Oscillator capacitor load configurations. More...
 

oscillator control APIs

static void OSC_HAL_SetExternalRefClkCmd (OSC_Type *base, bool enable)
 Enables the external reference clock for the oscillator. More...
 
static bool OSC_HAL_GetExternalRefClkCmd (OSC_Type *base)
 Gets the external reference clock enable setting for the oscillator. More...
 
static void OSC_HAL_SetExternalRefClkInStopModeCmd (OSC_Type *base, bool enable)
 Enables/disables the external reference clock in stop mode. More...
 
void OSC_HAL_SetCapacitor (OSC_Type *base, uint32_t bitMask)
 Sets the capacitor configuration for the oscillator. More...
 

Enumeration Type Documentation

Enumerator
kOscCapacitor2p 

2 pF capacitor load

kOscCapacitor4p 

4 pF capacitor load

kOscCapacitor8p 

8 pF capacitor load

kOscCapacitor16p 

16 pF capacitor load

Function Documentation

static void OSC_HAL_SetExternalRefClkCmd ( OSC_Type *  base,
bool  enable 
)
inlinestatic

This function enables the external reference clock output for the oscillator, OSCERCLK. This clock is used by many peripherals. It should be enabled at an early system initialization stage to ensure the peripherals can select and use it.

Parameters
baseOscillator register base address
enableenable/disable the clock
static bool OSC_HAL_GetExternalRefClkCmd ( OSC_Type *  base)
inlinestatic

This function gets the external reference clock output enable setting for the oscillator , OSCERCLK. This clock is used by many peripherals. It should be enabled at an early system initialization stage to ensure the peripherals could select and use it.

Parameters
baseOscillator register base address
Returns
Clock enable/disable setting
static void OSC_HAL_SetExternalRefClkInStopModeCmd ( OSC_Type *  base,
bool  enable 
)
inlinestatic

This function enables/disables the external reference clock (OSCERCLK) when an MCU enters the stop mode.

Parameters
baseOscillator register base address
enableenable/disable setting
void OSC_HAL_SetCapacitor ( OSC_Type *  base,
uint32_t  bitMask 
)

This function sets the specified capacitors configuration for the oscillator. This should be done in the early system level initialization function call based on the system configuration.

Parameters
baseOscillator register base address
bitMaskBit mask for the capacitor load option.

Example:

// To enable only 2 pF and 8 pF capacitor load, please use like this.