nRF51 SDK - S130 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
SPI Master Loopback Example

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. Both SPI_MASTER_0 and SPI_MASTER_1 are tested, first with shifting LSB first, then by shifting MSB first.

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:

  1. Compile and program the application.
  2. Observe that BSP_INDICATE_RCV_OK is indicated every second.
  3. BSP_INDICATE_FATAL_ERROR is indicated if an error occurred.