This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Can the software adjust the internal load capacitance of the nrf5340 crystal oscillator

Hello,

Purpose: Adjust 5340 frequency offset.

I want to use software adjust the internal load capacitance, but I don't know how to do it.

I found this below.

Can you give me some advice?

  • Hi,

    It looks like this is under discussion on how these values can be controlled. As it is today it they are set in:

    See zephyr/soc/arm/nordic_nrf/nrf53/soc.c: nordicsemi_nrf53_init

    Though you may also set this in the application by including hal/nrf_oscillators.h and call: 

    nrf_oscillators_lfxo_cap_set(NRF_OSCILLATORS, your_cap_value);

    Best regards,
    Kenneth

  • Thank you Kenneth, but I want to adjust the 32Mhz crystals.

  • You should be able to use the api in hal/nrf_oscillators.h for that also, see api here:

    /**
     * @brief Function for configuring the internal capacitors of HXFO.
     *
     * The capacitance of internal capacitors ranges from 7 pF to 20 pF in 0.5 pF steps.
     * To calculate the correct @p cap_value, use the following equation:
     * CAPVALUE = (1+FICR->XOSC32MTRIM.SLOPE/16) * (CAPACITANCE*2-14) + FICR->XOSC32MTRIM.OFFSET
     *
     * @param[in] p_reg     Pointer to the structure of registers of the peripheral.
     * @param[in] enable    True if internal capacitors are to be enabled, false otherwise.
     * @param[in] cap_value Value representing capacitance, calculated using provided equation.
     *                      Ignored when internal capacitors are disabled.
     */
    NRF_STATIC_INLINE void nrf_oscillators_hfxo_cap_set(NRF_OSCILLATORS_Type * p_reg,
                                                        bool                   enable,
                                                        uint32_t               cap_value);

    Just call this in the beginning of the application.

Related