OSCILLATORS HAL

group nrf_oscillators_hal

Hardware access layer for managing the OSCILLATORS peripheral.

Defines

NRF_OSCILLATORS_HAS_PLL

Symbol indicating whether PLL is present.

NRF_OSCILLATORS_HAS_CLOCK_QUALITY_IND

Symbol indicating whether clock quality indicator is present.

NRF_OSCILLATORS_HAS_LFXO_CAP_AS_INT_VALUE

Symbol indicating whether configuration of internal capacitor using integer value is present.

NRF_OSCILLATORS_HAS_LFXO_BYPASS

Symbol indicating whether LFXO bypass is present.

OSCILLATORS_HFXO_CAP_CALCULATE(p_ficr_reg, cap_val)

Macro for calculating HFXO internal capacitor value.

Depending on the SoC used, a range of capacitance of internal capacitors is as follows:

  • From 7 pF to 20 pF in 0.5 pF steps for nRF5340.

  • From 4 pF to 17 pF in 0.25 pF steps for other SoCs. This macro should be used to calculate argument’s value for nrf_oscillators_hfxo_cap_set function.

OSCILLATORS_LFXO_CAP_CALCULATE(p_ficr_reg, cap_val)

Macro for calculating LFXO internal capacitor value.

The capacitance of internal capacitors ranges from 4 pF to 18 pF in 0.5 pF steps. This macro should be used to calculate argument’s value for nrf_oscillators_lfxo_cap_set function.

NRF_OSCILLATORS_LFXO_CAP_EXTERNAL

Symbol specifying usage of external capacitors.

Typedefs

typedef uint32_t nrf_oscillators_lfxo_cap_t

LFXO capacitance type.

Enums

enum nrf_oscillators_hfxo_clock_quality_t

HFXO clock quality indicator.

Values:

enumerator NRF_OSCILLATORS_HFXO_CLOCK_QUALITY_NONE

Clock XOSC32M status is not defined.

enumerator NRF_OSCILLATORS_HFXO_CLOCK_QUALITY_STARTING

Clock XOSC32M has started but has not yet reached the specified frequency tolerance requirement fTOL_HFXO.

enumerator NRF_OSCILLATORS_HFXO_CLOCK_QUALITY_STARTED

Clock XOSC32M has started and is operating with the specified frequency tolerance requirement fTOL_HFXO.

enum nrf_oscillators_pll_freq_t

PLL frequencies.

Values:

enumerator NRF_OSCILLATORS_PLL_FREQ_64M

PLL 64 MHz frequency.

enumerator NRF_OSCILLATORS_PLL_FREQ_128M

PLL 128 MHz frequency.

Functions

NRF_STATIC_INLINE nrf_oscillators_hfxo_clock_quality_t nrf_oscillators_hfxo_clock_quality_get(NRF_OSCILLATORS_Type *p_reg)

Function for reading HFXO clock quality indicator.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Clock quality indicator value.

NRF_STATIC_INLINE void nrf_oscillators_pll_freq_set(NRF_OSCILLATORS_Type *p_reg, nrf_oscillators_pll_freq_t freq)

Function for setting PLL frequency.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • freq[in] New PLL frequency.

NRF_STATIC_INLINE nrf_oscillators_pll_freq_t nrf_oscillators_pll_freq_get(NRF_OSCILLATORS_Type *p_reg)

Function for getting PLL frequency.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns:

Current PLL frequency value.

NRF_STATIC_INLINE void nrf_oscillators_lfxo_bypass_set(NRF_OSCILLATORS_Type *p_reg, bool enable)

Function for enabling or disabling the bypass of LFXO with external clock source.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • enable[in] True if bypass is to be enabled (use with rail-to-rail external source). False if bypass is to be disabled (use with xtal or low-swing external source).

NRF_STATIC_INLINE void nrf_oscillators_lfxo_cap_set(NRF_OSCILLATORS_Type *p_reg, nrf_oscillators_lfxo_cap_t cap)

Function for configuring the internal capacitors of LFXO.

For SoCs other than nRF5340, to calculate the correct cap_value, use OSCILLATORS_LFXO_CAP_CALCULATE macro.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • cap[in] Capacitors configuration.

NRF_STATIC_INLINE void nrf_oscillators_hfxo_cap_set(NRF_OSCILLATORS_Type *p_reg, bool enable, uint32_t cap_value)

Function for configuring the internal capacitors of HFXO.

To calculate the correct cap_value, use OSCILLATORS_HFXO_CAP_CALCULATE macro.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • enable[in] True if internal capacitors are to be enabled, false otherwise.

  • cap_value[in] Value representing capacitance, calculated using provided equation. Ignored when internal capacitors are disabled.