| Kinetis SDK API Reference Manual 1.0.0-beta Freescale Semiconductor, Inc.

- Introduction
- Related Pages
- API Usage

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Macros | Enumerations
OSC HAL driver
Oscillator (OSC)

The section describes the programming interface of the OSC HAL driver. More...

## Macros
#define | kOscCapacitorMask (OSC_CR_SC2P_MASK | OSC_CR_SC4P_MASK | OSC_CR_SC8P_MASK | OSC_CR_SC16P_MASK)
| Oscillator capacitor load configurations mask.

## Enumerations
enum | osc_instance_t { kOsc0 = 0 }
| Oscillator instance. More...
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
void | osc_hal_enable_external_reference_clock (osc_instance_t instance)
| Enables the external reference clock for oscillator. More...
void | osc_hal_disable_external_reference_clock (osc_instance_t instance)
| Disables the external reference clock for oscillator. More...
void | osc_hal_enable_external_reference_clock_in_stop_mode (osc_instance_t instance)
| Enables the external reference clock in stop mode. More...
void | osc_hal_disable_external_reference_clock_in_stop_mode (osc_instance_t instance)
| Disables the external reference clock in stop mode. More...
void | osc_hal_enable_capacitor_config (osc_instance_t instance, uint32_t capacitorConfigs)
| Enables the capacitor configuration for oscillator. More...
void | osc_hal_disable_capacitor_config (osc_instance_t instance, uint32_t capacitorConfigs)
| Disables the capacitor configuration for specific oscillator. More...

### OSC Hal Driver

# Overview

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 provides a set of APIs used to access these SIM registers including enable/disable external reference clock and set the capacitor configurations.

# Oscillator Control register access APIs

Each Oscillator only has one control register, OSCx_CR. It provides an external reference clock enable, external reference clock stop enable and the capacitor load configuration settings.Example of OSC HAL access APIs
#include "osc/hal/fsl_osc_hal.h"
// Enable the external reference clock
osc_hal_enable_external_reference_clock(kOsc0);
// Disable the external reference clock
osc_hal_disable_external_reference_clock(kOsc0);
#include "osc/hal/fsl_osc_hal.h"
// Enable the osc0 capacitor 2p and 8p
osc_hal_enable_capacitor_config(kOsc0, kOscCapacitor2p | kOscCapacitor8p);
// Disable the osc0 capacitor 4p and 16p
osc_hal_disable_capacitor_config(kOsc0, kOscCapacitor4p | kOscCapacitor16p);

## Enumeration Type Documentation

enum osc_instance_t

Enumerator
kOsc0 | Oscillator 0.

enum osc_capacitor_config_t

Enumerator
kOscCapacitor2p | 2 pF capacitor load
kOscCapacitor4p | 4 pF capacitor load
kOscCapacitor8p | 8 pF capacitor load
kOscCapacitor16p | 16 pF capacitor load

## Function Documentation

void osc_hal_enable_external_reference_clock | ( | osc_instance_t | instance | ) |

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

Parameters

  instance | Oscillator instance

void osc_hal_disable_external_reference_clock | ( | osc_instance_t | instance | ) |

This function disables the external reference clock output for oscillator - that is the 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

  instance | Oscillator instance

void osc_hal_enable_external_reference_clock_in_stop_mode | ( | osc_instance_t | instance | ) |

This function enables the external reference clock (OSCERCLK) when MCU enters Stop mode.

Parameters

  instance | Oscillator instance

void osc_hal_disable_external_reference_clock_in_stop_mode | ( | osc_instance_t | instance | ) |

This function disables the external reference clock (OSCERCLK) when MCU enters Stop mode.

Parameters

  instance | Oscillator instance

void osc_hal_enable_capacitor_config | ( | osc_instance_t | instance,
|  | uint32_t | capacitorConfigs
| ) |  |

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

Parameters

  instance | Oscillator instance
  capacitorConfig | Capacitor configurations. Combination of OSC_CR_SCxP_MASK

void osc_hal_disable_capacitor_config | ( | osc_instance_t | instance,
|  | uint32_t | capacitorConfigs
| ) |  |

This function enables the specified capacitors configuration for the oscillator.

Parameters

  instance | Oscillator instance
  capacitorConfig | Capacitor configurations. Combination of OSC_CR_SCxP_MASK