18.4 Calibrating 16 MHz Crystal Oscillating Frequency in Prototype

In prototype boards, tune the oscillating frequency of the 16 MHz crystal to the desired frequency using the external load capacitors and when the XTAL_TRIM bits are with a value of 0x7. The user must tune the board with XTAL_TRIM as 0x7 to ensure that during production calibration, there is a scope to swing either side of the desired frequency to achieve the desired frequency tolerance. XTAL_TRIM bits of XOSC_CTRL register (AT86RF212B) controls the internal trimming capacitor value. Typically, in production, the frequency calibration is performed by measuring the frequency variation from the desired value and compensating for this offset by adjusting the XTAL_TRIM bits. Thereby, the internal trimming capacitance is either increased or decreased. The specific value of XTAL_TRIM where the frequency variation is within the limits set in production is stored in NVM. This value is loaded into XTAL_TRIM during boot-up of the firmware through the initialization routine. The limit in production can be set at +/-5 kHz for achieving the best possible frequency tolerance.
Note: The choice of crystal also has an impact on the frequency tolerance.

In order to configure XTAL_TRIM with value 0x7 for the calibration, modify the method tfa_continuous_tx_start() in the tfa.c file available in the Performance analyzer ASF example project. The following is the code snippet to be inserted in the tfa.c file.

void tfa_continuous_tx_start(continuous_tx_mode_t tx_mode, bool random_content)
{
	uint8_t txcwdata[128];
	uint8_t i;

	/* step 3,6: Channel is assumed to be set before */
	trx_reg_write(RG_TRX_STATE, CMD_TRX_OFF);
              trx_bit_write(SR_XTAL_TRIM,0x7); //Write XTAL_TRIM bits with a value 0x7
	/* step 7: Enable continuous transmission - step #1 */
	trx_reg_write(0x36, 0x0F);

This test can be done by generating a CW tone at a specific channel and measuring the frequency tolerance with a Spectrum analyzer. The following are the steps that must be performed during this calibration process.

  1. Load the SAMR30 device with Performance analyzer firmware. Refer to the certification user guide document on the prerequisites, installation and procedure to configure the SAMR30 in CW mode. Note that with the default FW, the CW tone will be generated at Fc -0.1 MHz. Refer to section 21, Continuous Transmission Test Mode of the SAMR30 Data Sheet, for more details.
  2. Follow the steps in section General Configuration and Continuous TX – CW Mode under the section Configuring SAMR30 in Different Test Modes to initiate a CW tone at a desired frequency. For reference, let the configuration be Channel 1, i.e., 906 MHz.
  3. Measure the frequency of the peak output with a spectrum analyzer. The difference between the measured value and 905.9 MHz, i.e., 906 – 0.1 = 905.9 MHz, is the frequency offset as observed in the board. This frequency offset could be adjusted to be as close as possible to the desired frequency by adjusting the external load capacitors added for 16 MHz crystal.
  4. Adjust the external capacitor to a nearby value and verify the frequency tolerance. Repeat the step until the lowest possible frequency tolerance is achieved.
  5. Verify the frequency tolerance in additional samples with the external load capacitor as identified in step 4.
  6. Freeze the BoM for the external load capacitor based on verification done in the above steps. It is recommended to perform the XTAL calibration in production and to arrive at the XTAL_TRIM value for each unit that results in an accurate clock source for RF.

The same steps can be done by routing the CLKM from AT86RF21B to the GPIO pins of ATSAMR30 through the GCLK I/O peripheral function. This allows the measurement to be done in < 16 MHz using a frequency counter.