The SPI Master Loopback Example demonstrates how to use a loopback for verifying the SPI master. To complete the loopback, the MOSI and MISO pins of the SPI master must be wired together.
TX_RX_MSG_LENGTH number of bytes are transmitted through the master. The received bytes are verified to be the same as the bytes transmitted. If there is an error, BSP_INDICATE_FATAL_ERROR is indicated.
The application starts with configuring the
Board Support Package
, then selected SPI master instances are tested continuously, each one by shifting LSB first, then by shifting MSB first (by default SPI0 and SPI1 instances are selected, this can be changed in the
nrf_drv_config.h
file).
BSP_INDICATE_RCV_OK
is indicated on the beginning of every transfer.
Setup
The name of the example is
spi_master_pca10028
. If you are not using the Keil Pack Installer, you can find the source code and project file of the example in the following folder:
<InstallFolder>\examples\peripheral\spi_master
Configuration:
- MOSI0 should be connected to MISO0.
- MOSI1 should be connected to MISO1.
Testing
Test the SPI Master Loopback Example application by performing the following steps:
- Compile and program the application.
- Observe that BSP_INDICATE_RCV_OK is indicated every second.
- BSP_INDICATE_FATAL_ERROR is indicated if an error occurred.