nRF5 SDK v12.1.0
Compiling and running a first example

To start developing your own application, you should first test that you set up your toolchain correctly. To do so, compile, program, and run a very simple example that does not use a SoftDevice, for example the Blinky Example.

Make sure that you have all required tools installed and that the board is connected to your computer. For nRF52 Development Kits, see Setting up the development kit. For nRF51 Development Kits, follow the steps in section 3 (Getting started) in the nRF51 Development Kit User Guide.

Erasing the board

Before you program an example, erase the contents of the board.

If no SoftDevice has been installed on the board, simply open Keil and select Flash > Erase.

If a SoftDevice has been installed on the board or if you are not sure, use nRFgo Studio to make sure that you erase the whole board. Select your device in the Device Manager pane. Then click the Erase All button. If you prefer to use a command line tool instead, use nrfjprog (which is installed with nRFgo Studio).

Running the example

To run the example:

  1. Navigate to the folder that contains the example project:
    1. Open the folder that contains the SDK files, thus the folder where you extracted the SDK zip file.
    2. Select the example that you want to run, for example, ...\examples\peripheral\blinky.
    3. Select the board that you want to use, for example, ...\pca10040.
    4. If you want to run the example with a SoftDevice, select the SoftDevice. Otherwise, select blank. So for running the Blinky Example without a SoftDevice, select ...\blank.
    5. Select the toolchain that you want to use. The following steps assume that you are using Keil 5, so select ...\arm5_no_packs.

      Navigate to the example project

  2. Double-click the uvprojx file to open the project in Keil.
  3. Build the project to compile all files.

    Rebuild all target files

  4. Download the code to flash memory to flash the project to the board. If Keil prompts you to update to the latest firmware version, select Yes.

    Download code to flash memory

  5. Test the example as described in the Testing section of the example documentation (Testing Blinky).

Documentation feedback | Developer Zone | Subscribe | Updated