Radio test

The Radio test sample demonstrates how to configure the radio in a specific mode and then test its performance. The sample provides a set of predefined commands that allow you to configure the radio in three modes:

  • Constant RX or TX carrier

  • Modulated TX carrier

  • RX or TX sweep

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Build target

nRF5340 DK

PCA10095

nrf5340dk_nrf5340

nrf5340dk_nrf5340_cpunet

nRF52840 DK

PCA10056

nrf52840dk_nrf52840

nrf52840dk_nrf52840

nRF52 DK

PCA10040

nrf52dk_nrf52832

nrf52dk_nrf52832

nRF21540 DK

PCA10112

nrf21540dk_nrf52840

nrf21540dk_nrf52840

You can use any one of the development kits listed above.

Note

On nRF5340 DK, the sample is designed to run on the network core.

The sample also requires one of the following testing devices:

Note

You can perform the radio test also using a spectrum analyzer. This method of testing is not covered by this documentation.

nRF21540 front-end module

You can add support for the nRF21540 front-end module (FEM) to the sample.

To add support for the nRF21540 FEM, build the sample for a board containing nRF21540 FEM like nrf21540dk_nrf52840 or create a devicetree overlay file describing how FEM is connected to nRF5 SoC in your device.

Note

If you use the nRF21540 EK, append nrf21540_ek shield to your build command instructing build system to append the appropriate devicetree overlay file. If you use the nRF21540 DK, build your application for the nrf21540dk_nrf52840 board. The devicetree for the nRF21540 DK already contains the required FEM configuration, so you do not need to set an additional build option.

For example, to build the sample from the command line for an nRF5340 DK with an attached nRF21540 EK, invoke the following command within the sample directory: west build -b nrf5340dk_nrf5340_cpunet -- -DSHIELD=nrf21540_ek

Note

The nRF5340 DK network core peripherals, like UART and SPI, share an ID and a base address. To configure the nRF21540 front-end module gain, write the gain value over the SPI. In samples, UART is used as a control interface or shell transport. To send the gain value UART is temporary disabled and restarted after the SPI transfer.

For more details refer to the following documentation:

You can configure the nRF21540 front-end module (FEM) transmitted power gain, antenna output and activation delay using the main shell commands of the User interface.

Skyworks front-end module

The Skyworks SKY66114 and SKY66403 are front-end module (FEM) devices that support the 2-pin PA/LNA interface. You can also use other Skyworks FEM devices that provide the same hardware interface.

To use the generic FEM implementation with Skyworks front-end modules refer to Adding support for Skyworks front-end module for details.

Use case of incomplete physical connections to the FEM module

The devicetree configuration allows you to use a minimal pin configuration. Connect all unused pins to the fixed logic level as instructed in the official documentation. For example csd-gpios is an optional pin that sets the device into sleep mode. If this pin is not controlled by the driver, it must be connected to the fixed logic level.

You can configure the Skyworks front-end module (FEM) antenna output and activation delay using the main shell commands of the User interface.

Overview

To run the tests, connect to the development kit through the serial port and send shell commands. Zephyr’s Shell module is used to handle the commands. At any time during the tests, you can dynamically set the radio parameters, such as output power, bit rate, and channel. In sweep mode, you can set the time for which the radio scans each channel from 1 millisecond to 99 milliseconds, in steps of 1 millisecond. The sample also allows you to send a data pattern to another development kit.

The sample first enables the high frequency crystal oscillator and configures the shell. You can then start running commands to set up and control the radio. See User interface for a list of available commands.

Note

For the IEEE 802.15.4 mode, the start channel and the end channel must be within the channel range of 11 to 26. Use the start_channel and end_channel commands to control this setting.

User interface

Main shell commands (in alphabetical order)

Command

Argument

Description

cancel

Cancel the sweep or the carrier.

data_rate

<sub_cmd>

Set the data rate.

end_channel

<channel>

End channel for the sweep (in MHz, as difference from 2400 MHz).

fem

<sub_cmd>

Set front-end module (FEM) parameters.

output_power

<sub_cmd>

Output power set.

parameters_print

Print current delay, channel, and other parameters.

print_rx

Print the received RX payload.

start_channel

<channel>

Start channel for the sweep or the channel for the constant carrier (in MHz, as difference from 2400 MHz).

start_duty_cycle_modulated_tx

<duty_cycle>

Duty cycle in percent (two decimal digits, between 01 and 99).

start_rx

Start RX.

start_rx_sweep

Start the RX sweep.

start_tx_carrier

Start the TX carrier.

start_tx_modulated_carrier

<packet_num>

Start the modulated TX carrier (continuous TX mode is used if no argument is provided).

start_tx_sweep

Start the TX sweep.

time_on_channel

<time>

Time on each channel in ms (between 1 and 99).

toggle_dcdc_state

<state>

Toggle DC/DC converter state.

transmit_pattern

<sub_cmd>

Set transmission pattern.

Building and running

This sample can be found under samples/peripheral/radio_test in the nRF Connect SDK folder structure.

See Building and programming an application for information about how to build and program the application.

Note

On the nRF5340 DK board (PCA10095), the Radio test sample is a standalone network sample that does not require any counterpart application sample. Program the application core to boot up the network core. Use any sample for this, for example nRF5340: Empty firmware for application core. The nRF5340: Empty firmware for application core is built and programmed automatically by default. If you want to program another sample for the application core, unset the CONFIG_NCS_SAMPLE_EMPTY_APP_CORE_CHILD_IMAGE option.

Testing

After programming the sample to your development kit, complete the folowing steps to test it in one of the following two ways:

Note

For the nRF5340 DK board (PCA10095), see Getting logging output for information about the COM terminals on which the logging output is available.

Testing with another development kit

  1. Connect both development kits to the computer using a USB cable. The kits are assigned a COM port (Windows) or ttyACM device (Linux), which is visible in the Device Manager.

  2. Connect to both kits with a terminal emulator (for example, PuTTY). See How to connect with PuTTY for the required settings.

  3. Run the following commands on one of the kits:

    1. Set the data rate with the data_rate command to ble_2Mbit.

    2. Set the transmission pattern with the transmit_pattern command to pattern_11110000.

    3. Set the radio channel with the start_channel command to 40.

  4. Repeat all steps for the second kit.

  5. On both kits, run the parameters_print command to confirm that the radio configuration is the same on both kits.

  6. Set one kit in the Modulated TX Carrier mode using the start_tx_modulated_carrier command.

  7. Set the other kit in the RX Carrier mode using the start_rx command.

  8. Print the received data with the print_rx command and confirm that they match the transmission pattern (0xF0).

Testing with RSSI Viewer

  1. Connect the kit to the computer using a USB cable. The kit is assigned a COM port (Windows) or ttyACM device (Linux), which is visible in the Device Manager.

  2. Connect to the kit with a terminal emulator (for example, PuTTY). See How to connect with PuTTY for the required settings.

  3. Set the start channel with the start_channel command to 20.

  4. Set the end channel with the end_channel command to 60.

  5. Set the time on channel with the time_on_channel command to 50 ms.

  6. Set the kit in the TX sweep mode using the start_tx_sweep command.

  7. Start the RSSI Viewer application and select the kit to communicate with.

  8. On the application chart, observe the TX sweep in the form of a wave that starts at 2420 MHz frequency and ends with 2480 MHz.

Dependencies

This sample has the following nrfx dependencies:

  • nrfx/drivers/include/nrfx_timer.h

  • nrfx/hal/nrf_nvmc.h

  • nrfx/hal/nrf_power.h

  • nrfx/hal/nrf_radio.h

  • nrfx/hal/nrf_rng.h

In addition, it uses the following Zephyr libraries: