LFXO IDAC calibration

The LFXO IDAC calibration sample finds the initial IDAC code for the Pierce mode of the low-frequency crystal oscillator (LFXO) on your board. You can use the result to configure the idac-init devicetree property of the LFXO.

Requirements

The sample supports the following development kit:

Hardware platforms

PCA

Board name

Board target

nRF7120 DK

PCA10217

nrf7120dk

nrf7120dk/nrf7120/cpuapp

Overview

In Pierce mode, the amplitude of the LFXO oscillation depends on the current that the IDAC supplies to the oscillator. The IDAC code that keeps the amplitude within the peak detector thresholds depends on the crystal, the load capacitance, and the board design.

The sample keeps the LFXO in Pierce mode and runs an amplitude search in the following steps:

  1. Disables the automatic amplitude control, so that the IDAC follows the initial IDAC code directly.

  2. Runs a successive approximation over the 5-bit IDAC code. For each code, the sample drives the IDAC to its minimum or maximum value until the amplitude falls within the peak detector thresholds. It then applies the code and monitors the peak detector. If the amplitude stays within the thresholds, the code is accepted. Otherwise, the sample tries a lower or higher code.

  3. Prints the devicetree configuration to use.

The result is valid only for the load capacitance used during the search. Run the sample again if you change the crystal or the load-capacitance-femtofarad devicetree property of the LFXO.

Building and running

This sample can be found under samples/peripheral/lfxo_idac_calibration in the nRF Connect SDK folder structure.

To build the sample, follow the instructions in Building an application for your preferred building environment. See also Programming an application for programming steps and Testing and optimization for general information about testing and debugging in the nRF Connect SDK.

Note

When building repository applications in the SDK repositories, building with sysbuild is enabled by default. If you work with out-of-tree freestanding applications, you need to manually pass the --sysbuild parameter to every build command or configure west to always use it.

Testing

After programming the sample to your development kit, complete the following steps to test it:

  1. Connect to the kit with a terminal emulator (for example, the Serial Terminal app). See Testing and optimization for the required settings and steps.

  2. Reset the kit.

  3. Wait until the sample prints the result.

    The output is similar to the following:

    LFXO IDAC calibration
    Add the following to the devicetree:
    &lfxo {
            idac-init = <8>;
    };
    
  4. Add the printed configuration to the devicetree overlay of your application.

Dependencies

This sample has the following nrfx dependency:

In addition, it uses the following Zephyr library: