Setting up an example project on the nRF51 DK


This tutorial has been updated, go here for the latest version.

Getting started with nRF51 DK

This tutorial will help you get started with a simple BLE service with your new nRF51 Development Kit. The tutorial will explain in detail how to set up and start working with a BLE example project, and how to proceed with testing and using the service. In particular, the tutorial will show how to setup the UART over BLE service.


In order to follow this guide, it is necessary to have read and followed the nRF51 DK user guide. The user guide explains the required tools and software, and how to set them up. It also gives a brief explanation of the layout and hardware of the Development Kit, making it easier to follow this tutorial.

Preparing the Development Kit

Before the DK can be programmed with a user application, it must be flashed with the correct SoftDevice. The SoftDevice is a preprogrammed hex file that contains all the necessary functions to control the radio. These functions are hidden from the user so that all one has to think about is creating the application. Depending on which chip and SDK is being used, the correct Softdevice must be chosen. To determine which Softdevice you need, the following compatibility matrix can be used. The differences between the softdevices are listed in the SDK documentation.

For this tutorial we will use SoftDevice s130, s130 can act in both peripheral and central roles. In order to figure out which SoftDevice is compatible with which SDK version we can consult the compatibility matrix. We will use s130 version 2.0.0 which is compatible with nRF5 SDK 11.0.0. For further reference the markings on the nRF51 development kit indicate that the chip is revision 3.

Now we need to flash the softdevice onto the development kit. To do this, do the following:

  • Open nRFgo Studio
  • Connect the nRF51 DK to the computer with a USB cable

image description

  • In nRFgo Studio, the device should pop up under nRF51 Development Boards
  • In nRFgo Studio, click on the device, and then click Erase all.
  • Go to the Program SoftDevice tab on the right side
  • Click Browse and locate the s130_nrf51_1.0.0_softdevice.hex file in [extract_location]\components\softdevice\s130\hex, where extract_location is the place you unzipped SDK 10.
  • Click Program. The screen will now look like this:

image description

The device is now ready, and can be programmed with a user application.

Opening the project

There are two options for accessing the Nordic SDK, these are the classic .zip structure and something called a Software Pack. We recommend using .zip structure, which is covered in this tutorial.

  • Navigate to [extract_location]\examples\ble_peripheral\ble_app_uart\pca10028\s130\arm5_no_packs

  • Open the µVision5 project ble_app_uart_s130_pca10028

If you see the following message, click “yes”.

image description

If you are using the PCA10028 board (nRF51 DK) you can now compile the code and load the program onto the board. If you are using a different board, however, you must change a definition in the project to make it work as expected.

Preparing the project for a different board

In order to make it easy to port projects between different boards, all projects come with a board support package. In the main.c file, it can be seen that bsp.h is included, which in turn includes boards.h. In the latter file we see some preprocessor directives that check if a certain symbol is defined, and if it is a corresponding header file will be included. These header files are the board-specific files that map the correct pins to the correct external components. For example, on the nrf6310 motherboard, LED_0 is connected to pin 8, while on the PCA_10001 board, LED_0 is connected to pin 18. Porting a project to a different board is then a matter of simply defining the correct board in the project. In Keil, project defines can be entered in the target options.

  • Go to Projects -> Options for Target, or click the shortcut as shown below

image description

  • In the C/C++ tab, change the BOARD_PCA10028 symbol in the list of Preprocessor Symbols to the board you wish.

  • Click Ok

Compiling and flashing the project

The project can now be compiled and flashed onto the development kit.

  • Go to Project -> Build Target, or press the Build button shown on the left below.
  • When the code has compiled and the board is connected to the computer, click Load as shown above on the right, and the program will be flashed onto the chip. Make sure you have connected the board to your computer with the USB cable. The program is now running, and you should notice LED1 blinking on the board approximately every 2 seconds.

If everything is working as expected, you can move on to the next tutorial, which will show how to test and debug the ble_app_uart application you have built in this tutorial.