nRF51 SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
SPI master Loopback Example

Modules

 main.c
 SPI Master Loopback Example Application main file.
 

Detailed Description

The SPI master Loopback Example is for demonstrating the SPI Master using a Loopback for verification. There are two ways to make the loopback complete: Either connect and configure a slave to transmit the received bytes or wire the MOSI and MISO pins of the SPI master together. Both SPI0 and SPI1 are tested in this example. It uses the hardware delivered in the nRF51822 Development Kit.

TX_RX_MSG_LENGTH number of bytes are transmitted through the master and the received bytes are verified to be the same as transmitted. If there is an error, the GPIO pin for the relevant SPI module is set high to show the error

If there is error from both modules, both pins go high and the application loops infinitely.

The application is started with configuring GPIO. Both SPI0 and SPI1 are tested, first with shifting lsb first, then by shifting msb first. If there is an error, the LED will be turned on.

Setup

Instructions on how to set up the nRFgo Motherboard: nRFgo Motherboard Setup (nRF6310).

If a slave is configured to transmit the received bytes:

If MOSI and MISO are connected together:

LED assignments:

Testing

The SPI master Loopback Example Application can be tested as follows:

  1. Compile and program the application.
  2. Observe that no LEDs are lit on the board.
  3. If LED 0 is lit, SPI0 had an error.
  4. If LED 1 is lit, SPI1 had an error.