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
Overview¶
You can run the tests by connecting to the development kit through the serial port and sending 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 starts with enabling the high frequency crystal oscillator and configuring 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.
Requirements¶
The sample supports the following development kits:
Hardware platforms |
PCA |
Board name |
Build target |
---|---|---|---|
PCA10095 |
|
||
PCA10056 |
|
||
PCA10040 |
|
||
nRF21540 DK |
PCA10112 |
|
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:
Another development kit with the same sample. See Testing with another development kit.
Another development kit connected to a PC with RSSI Viewer application (available in the nRF Connect for Desktop). See Testing with RSSI Viewer.
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.
Set -DNRF21540EK_FEM=y
when you invoke west build
or cmake
in your sample directory.
Follow the instructions in Providing CMake options.
For example:
west build -b nrf5340dk_nrf5340_cpunet -- -DNRF21540EK_FEM=y
When you set NRF21540EK_FEM=y
the dts-nrf21540-fem.overlay
devicetree overlay file is used to override the default settings.
The configuration from this file is merged with the additional development kit overlay file from the boards
folder if it exists.
The dts-nrf21540-fem.overlay
is located in the samples/peripheral/radio_test/configuration
folder.
Make sure that the GPIOs and the SPI configuration in the file correspond to those in which your front-end module is connected.
Note
You must set NRF21540EK_FEM=y
if you use the nRF21540 EK.
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.
Sometimes, you may need to add an extra overlay file.
The easiest way to add the file when building is to set it in the DTC_OVERLAY_FILE
variable.
However, that will override the default settings.
When you set the DTC_OVERLAY_FILE
variable, you must specify all overlay files that are needed for building.
Follow the instructions in Providing CMake options to specify the DTC_OVERLAY_FILE
variable.
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 -- -DDTC_OVERLAY_FILE="boards/nrf5340dk_nrf5340_cpunet.overlay;../configuration/dts-nrf21540-fem.overlay;your_overlay_file.overlay"
See Set devicetree overlays for different ways of adding the overlay file.
Alternatively, you can copy the contents of dts-nrf21540-fem.overlay
to the board’s overlay file.
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.
The nRF21540 transmitted power gain, antenna and an activation delay can be configured using the user interface User interface.
User interface¶
Command |
Argument |
Description |
---|---|---|
cancel |
Cancel the sweep or the carrier. |
|
data_rate |
<sub_cmd> |
Set the data rate. |
end_channel |
<channel> |
End the channel for the sweep. |
nRF21540 |
<sub_cmd> |
Set nRF21540 Front-End-Module 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 the channel for the sweep or the channel for the constant carrier. |
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 (between 1 ms and 99 ms). |
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 a sample 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. However, you must still program the application core to boot up the network core. You can use any sample for this, for example nRF5340: Empty firmware for application core.
Testing¶
After programming the sample to your development kit, you can test it in one of 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¶
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.
Connect to both kits with a terminal emulator (for example, PuTTY). See How to connect with PuTTY for the required settings.
Run the following commands on one of the kits: #. Set the data rate with the
data_rate
command toble_2Mbit
. #. Set the transmission pattern with thetransmit_pattern
command topattern_11110000
. #. Set the radio channel with thestart_channel
command to 40.Repeat all steps for the second kit.
On both kits, run the
parameters_print
command to confirm that the radio configuration is the same on both kits.Set one kit in the Modulated TX Carrier mode using the
start_tx_modulated_carrier
command.Set the other kit in the RX Carrier mode using the
start_rx
command.Print the received data with the
print_rx
command and confirm that they match the transmission pattern (0xF0).
Testing with RSSI Viewer¶
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.
Connect to the kit with a terminal emulator (for example, PuTTY). See How to connect with PuTTY for the required settings.
Set the start channel with the
start_channel
command to 20.Set the end channel with the
end_channel
command to 60.Set the time on channel with the
time_on_channel
command to 50ms.Set the kit in the TX sweep mode using the
start_tx_sweep
command.Start the RSSI Viewer application and select the kit to communicate with.
On the application chart, observe the TX sweep in the form of a wave that starts at 2420 MHz frequency and ends with 2480MHz.
Dependencies¶
This sample uses 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:
-
drivers/clock_control.h
-
include/init.h
-
include/shell/shell.h