18.4 Calibrating 16 MHz Crystal Oscillating Frequency in Prototype
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.
- 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.
- 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.
- 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.
- Adjust the external capacitor to a nearby value and verify the frequency tolerance. Repeat the step until the lowest possible frequency tolerance is achieved.
- Verify the frequency tolerance in additional samples with the external load capacitor as identified in step 4.
- 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.