<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<meta name="copyright" content="(C) Copyright 2026" />
<meta name="DC.rights.owner" content="(C) Copyright 2026" />
<meta name="generator" content="DITA-OT" /><meta name="DC.type" content="concept" />
<meta name="DC.title" content="Determine the trim value" />
<meta name="abstract" content="You can use a transmit-based or receive-based approach for determining the trim value. The choice depends on the available test equipment. The receive-based approach yields quicker results and is better for trimming multiple units simultaneously. The trim accuracy is the same with either approach." />
<meta name="description" content="You can use a transmit-based or receive-based approach for determining the trim value. The choice depends on the available test equipment. The receive-based approach yields quicker results and is better for trimming multiple units simultaneously. The trim accuracy is the same with either approach." />
<meta name="DC.relation" scheme="URI" content="../../APP/nan_043/xtalxo_freq_trimming.html" />
<meta name="prodname" content="nRF7002" />
<meta name="prodname" content="nRF7001" />
<meta name="prodname" content="nRF7000" />
<meta name="prodname" content="nrf70-series" />
<meta name="prodname" content="application-notes" />
<meta name="DC.format" content="XHTML" />
<meta name="DC.identifier" content="find_trim_value" />
<link rel="stylesheet" type="text/css" href="../../commonltr.css" />
<title>Determine the trim value</title>
</head>
<body id="find_trim_value">

<div class="productversion"><span>nRF7002</span></div><div id="headerlinks"><span class="copyURL"><a href="#" id="theURL">Copy URL</a></span></div>
 <h1 class="title topictitle1" id="ariaid-title1">Determine the trim value</h1>

 
 
 <div class="body conbody"><p class="shortdesc">You can use a transmit-based or receive-based approach for determining the trim value.
        The choice depends on the available test equipment. The receive-based approach yields
        quicker results and is better for trimming multiple units simultaneously. The trim accuracy
        is the same with either approach. </p>

        <p class="p">The crystal oscillator trim range is 0 to 127, where 0 represents the highest frequency
            the crystal oscillator generates, while 127 represents the lowest frequency.</p>

        <div class="section" id="find_trim_value__section_of5_z2d_51c"><h2 class="title sectiontitle">Transmit-based approach</h2>
            
            <p class="p">To determine the trim value, the unit to be trimmed transmits either a modulated
                packet or a carrier wave at a known frequency. Measure the frequency offset using a
                    <a href="../../dita_common/glossary/glossary.html#vsa" title="A signal analyzer capable of analyzing digitally-modulated radio signals that may use any of a large number of digital modulation formats."><dfn class="term abbreviated-form">Vector Signal Analyzer (VSA)</dfn></a> for a modulated packet or a <a href="../../dita_common/glossary/glossary.html#sa" title="An instrument that measures the magnitude of an input signal versus frequency within the full frequency range of the instrument."><dfn class="term abbreviated-form">Spectrum Analyzer (SA)</dfn></a> for a carrier wave. This is repeated with different trim values
                until the minimum <a href="../../dita_common/glossary/glossary.html#cfo" title="The frequency offset from the expected carrier wave frequency or channel center frequency."><dfn class="term abbreviated-form">Carrier Frequency Offset (CFO)</dfn></a> is found. This value is then
                programmed into the <a href="../../dita_common/glossary/glossary.html#otp" title="A type of non-volatile memory that permits data to be written to memory only once."><dfn class="term abbreviated-form">One Time Programmable (OTP) memory</dfn></a>.</p>

            <p class="p">The following diagram shows the CALIB_XO process.</p>

            <div class="fig fignone" id="find_trim_value__fig_mpc_h4v_fwb"><span class="figcap"><span class="fig--title-label">Figure 1. </span>CALIB_XO process for transmit-based approach</span>
                
                <div class="imagecenter"><img class="image" id="find_trim_value__image_npc_h4v_fwb" src="Images/calib_xo_process.svg" alt="CALIB_XO process for transmit-based approach" /></div>
            </div>

            <p class="p">The process shown in the diagram is based on searching for the minimum CFO. Multiple
                approaches can be used. The following example is based on the bisection or binary
                search method.</p>

            <pre class="pre codeblock" id="find_trim_value__codeblock_rmx_2wt_cwb"><code>L=0, H=127
minCFO=1e6 
For i in range(7)  
    trimVal = (INT) (L+H)/2 
    Set crystal oscillator offset to trimVal 
    Transmit modulated packet or carrier wave 
    Measure CFO on VSA or SA  
    if abs(CFO) &lt; minCFO: 
         minCFO = abs(CFO) 
         minTrimVal = trimVal 
    L= trimVal if CFO &gt; 0 else H= trimVal</code></pre>
            <p class="p">The following table provides example Wi-Fi® Radio test commands for performing the steps described
                in the algorithm.</p>

            
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="find_trim_value__table_chy_jms_2wb" class="table" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 1. </span>Wi-Fi Radio test commands for transmit-based approach</span></caption><colgroup><col style="width:50%" /><col style="width:50%" /></colgroup><thead class="thead" style="text-align:left;">
                        <tr class="row">
                            <th class="entry cellrowborder" style="vertical-align:top;" id="d4953e103">Step</th>

                            <th class="entry cellrowborder" style="vertical-align:top;" id="d4953e106">Commands</th>

                        </tr>

                    </thead>
<tbody class="tbody">
                        <tr class="row">
                            <td class="entry cellrowborder" style="vertical-align:top;" headers="d4953e103 ">Set crystal oscillator offset to trimVal</td>

                            <td class="entry cellrowborder" style="vertical-align:top;" headers="d4953e106 ">
                                <pre class="pre codeblock" id="find_trim_value__codeblock_b3c_4c4_fwb"><code>wifi_radio_test set_xo_val &lt;trimVal&gt;</code></pre>
                            </td>

                        </tr>

                        <tr class="row">
                            <td class="entry cellrowborder" style="vertical-align:top;" headers="d4953e103 ">Transmit a modulated packet (for example, legacy 6 Mbps in 2.437
                                GHz)</td>

                            <td class="entry cellrowborder" style="vertical-align:top;" headers="d4953e106 ">
                                <pre class="pre codeblock" id="find_trim_value__codeblock_g3c_4c4_fwb"><code>wifi_radio_test init 6 
wifi_radio_test tx_pkt_tput_mode 0 
wifi_radio_test tx_pkt_rate 6  
wifi_radio_test tx_power 10 
wifi_radio_test tx 1 </code></pre>
                            </td>

                        </tr>

                        <tr class="row">
                            <td class="entry cellrowborder" style="vertical-align:top;" headers="d4953e103 ">Alternative - transmit a carrier wave (for example, at 2.439
                                GHz)</td>

                            <td class="entry cellrowborder" style="vertical-align:top;" headers="d4953e106 ">
                                <pre class="pre codeblock" id="find_trim_value__codeblock_h3c_4c4_fwb"><code>wifi_radio_test init 6
wifi_radio_test tx_tone_freq 2
wifi_radio_test tx_power 10 
wifi_radio_test tx_tone 1</code></pre>
                            </td>

                        </tr>

                        <tr class="row">
                            <td class="entry cellrowborder" style="vertical-align:top;" headers="d4953e103 ">Update the OTP memory register CALIB_XO with the required trim
                                value</td>

                            <td class="entry cellrowborder" style="vertical-align:top;" headers="d4953e106 ">
                                <pre class="pre codeblock" id="find_trim_value__codeblock_i3c_4c4_fwb"><code>wifi_radio_ficr_prog otp_write_params 0x130 &lt;minTrimVal&gt; </code></pre>
                            </td>

                        </tr>

                    </tbody>
</table>
</div>

            <p class="p">Reboot the system to activate the trim values for TX/RX operations.</p>

        </div>

        <div class="section" id="find_trim_value__section_ght_hfd_51c"><h2 class="title sectiontitle">Receive-based approach</h2>
            
            <p class="p">To determine the trim value, the unit to be trimmed receives a carrier wave at a
                known frequency transmitted from a <a href="../../dita_common/glossary/glossary.html#vsg" title="A signal generator capable of generating digitally-modulated radio signals that may use any of a large number of digital modulation formats."><dfn class="term abbreviated-form">Vector Signal Generator (VSG)</dfn></a> or similar test
                equipment. The unit to be trimmed measures the CFO at each possible trim value and
                reports the trim value with the minimum offset. This value is then programmed into
                the OTP memory.</p>

            <p class="p">The following diagram shows the CALIB_XO process.</p>

            <div class="fig fignone" id="find_trim_value__fig_vpv_vkd_51c"><span class="figcap"><span class="fig--title-label">Figure 2. </span>CALIB_XO process for receive-based approach</span>
                
                <div class="imagecenter"><img class="image" id="find_trim_value__image_wpv_vkd_51c" src="Images/calib_xo_process_receive-based.svg" alt="CALIB_XO process for receive-based approach" /></div>
            </div>

            <p class="p">The VSG can be connected to the unit to be trimmed with either a cable (recommended)
                or antenna. The target RSSI is –50 dBm, with ±10 dB tolerance on this target. Any
                channel can be used as long as the VSG can transmit a carrier wave at 0.5 MHz above
                the channel center frequency. Theoretically, higher frequency channels would result
                in improved estimation accuracy, but in practice the difference is not
                noticeable.</p>

            <p class="p">The following table provides example Wi-Fi Radio test commands for performing the
                steps described in the algorithm.</p>

            
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="find_trim_value__table_otg_2md_51c" class="table" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 2. </span>Wi-Fi Radio test commands for receive-based approach</span></caption><colgroup><col style="width:50%" /><col style="width:50%" /></colgroup><thead class="thead" style="text-align:left;">
                        <tr class="row">
                            <th class="entry cellrowborder" style="vertical-align:top;" id="d4953e215">Step</th>

                            <th class="entry cellrowborder" style="vertical-align:top;" id="d4953e218">Commands</th>

                        </tr>

                    </thead>
<tbody class="tbody">
                        <tr class="row">
                            <td class="entry cellrowborder" style="vertical-align:top;" headers="d4953e215 ">Set operating channel (for example, channel 6)</td>

                            <td class="entry cellrowborder" style="vertical-align:top;" headers="d4953e218 ">
                                <pre class="pre codeblock" id="find_trim_value__codeblock_ptg_2md_51c"><code>wifi_radio_test init 6</code></pre>
                            </td>

                        </tr>

                        <tr class="row">
                            <td class="entry cellrowborder" style="vertical-align:top;" headers="d4953e215 ">Initiate CFO measurement sweep</td>

                            <td class="entry cellrowborder" style="vertical-align:top;" headers="d4953e218 ">
                                <pre class="pre codeblock"><code>wifi_radio_test compute_optimal_xo_val</code></pre>
                            </td>

                        </tr>

                        <tr class="row">
                            <td class="entry cellrowborder" style="vertical-align:top;" headers="d4953e215 ">Update the OTP memory register CALIB_XO with the required trim
                                value</td>

                            <td class="entry cellrowborder" style="vertical-align:top;" headers="d4953e218 ">
                                <pre class="pre codeblock" id="find_trim_value__codeblock_stg_2md_51c"><code>wifi_radio_ficr_prog otp_write_params 0x130 &lt;minTrimVal&gt; </code></pre>
                            </td>

                        </tr>

                    </tbody>
</table>
</div>

            <p class="p">Reboot the system to activate the trim values for TX/RX operations.</p>

        </div>

 </div>

<div class="related-links">
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../../APP/nan_043/xtalxo_freq_trimming.html" title="The IEEE 802.11 specification defines the worst-case frequency offset that can be tolerated, measured in ppm.">Crystal/crystal oscillator frequency trimming</a></div>
</div>
</div></body>
</html>