Determine the trim value

To determine the trim value, it is recommended to transmit at a known frequency a modulated packet or carrier wave. Then measure the frequency offset using a Vector Signal Analyzer (VSA) for a modulated packet or a Spectrum Analyzer (SA) for a carrier wave. This is repeated with different trim values until the minimum Carrier Frequency Offset (CFO) is found. This value is then programmed into the One Time Programmable (OTP) memory.

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.

The following diagram shows the CALIB_XO process.

Figure 1. CALIB_XO process
CALIB_XO process

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/binary search method.

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) < minCFO: 
         minCFO = abs(CFO) 
         minTrimVal = trimVal 
    L= trimVal if CFO > 0 else H= trimVal

The following table provides example Wi-FiĀ® Radio test commands for performing the steps described in the algorithm.

Table 1. Wi-Fi Radio test commands
Step Commands
Set crystal oscillator offset to trimVal
wifi_radio_test set_xo_val <trimVal>
Transmit a modulated packet (for example, legacy 6 Mbps in 2.437 GHz)
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 
Alternative - transmit a carrier wave (for example, at 2.439 GHz)
wifi_radio_test init 6
wifi_radio_test tx_tone_freq 2
wifi_radio_test tx_power 10 
wifi_radio_test tx_tone 1
Update the OTP memory register CALIB_XO with the required trim value
wifi_radio_ficr_prog otp_write_params 0x130 <minTrimVal> 

Reboot the system to activate the trim values for TX/RX operations.