Step by Step Guide to Setup and Start Developing with the nRF51 DK and Keil

The purpose of this blog is to provide a step by step guide to help a developer, starting off with the Nordic Semiconductor nRF51 DK, get the tools installed and get the software (SW) development environment setup so that the user can start developing with the nRF51 DK.

1.0 Requirements

The following hardware is required for this guide.

  1. A laptop/PC running Windows XP SP3 or higher, with at least one free USB port, and knowledge of whether the Windows operating system (OS) running on the machine is a 32-bit or 64-bit OS.
  2. Nordic Semiconductor’s nRF51 DK

2.0 Setting UP the nRF51 DK Related SW Tools

  1. Download the document nRF51-DK - User Guide v1_0.pdf

  2. Listed below in more detail, and with the links to the referenced SW tools, are steps in Sec. 3, “Getting Started” of the nRF51-DK - User Guide v1_0.pdf document.

a. Download and install nRFgo Studio (which includes the nRF Tools package; JLinkARM, JLink CDC, nRFjprog, and mergehex) from one of the following links. Use this link, https://www.nordicsemi.com/eng/nordic/download_resource/46414/58/12750323, if the PC/Laptop where you will be setting up the toolchain, has a 64-bit Windows OS, OR, use this link, https://www.nordicsemi.com/eng/nordic/download_resource/38915/56/78083215, if the PC/laptop has a 32-bit Windows OS.

b. Download and install the latest evaluation version of Keil for ARM from https://www.keil.com/arm/demo/eval/arm.htm. NOTE: It is recommended that the size-limited evaluation version be selected instead of the 30-day evaluation version, as the former does not have a time limit. The size-limited version of Keil is limited to 32 Kbytes of compiled/linked code size, and most of the SW examples included with the nRF51 SDK are smaller than this size limit.

c. Installing the Nordic Semiconductor Packs for Keil: Download the latest nRF51 Software Development Kit (SDK) with packs, currently v.9.0.0, by clicking on this hyperlink: nRF51_SDK_9.0.0_2e23562_packs.zip. Extract all the files from this zip file to a folder of your choice. Navigate to this folder, and run the file "install.bat" by double-clicking on it, use the recommended answer to the question that will be asked in the command window that opens up, and wait until the pack installation is complete before closing this command window.

d. NOTE: The directions in the following steps refer to the examples extracted from the nRF51 SDK zip file that does NOT contain packs. To get these examples, download the following nRF51 SDK file: nRF51_SDK_9.0.0_2e23562.zip. Extract all the files from this zip file to a folder of your choice. (NOTE: The instructions in steps below assume the SDK files are extracted to the folder "C:\Nordic Semiconductor\nRF51 SDK_v9.0.0".)

  1. Download one of the S110, S120, or S130 softdevice (SD) zip files from the links below.

a. S110 – BLE peripheral only protocol stack: s110_nrf51_8.0.0.zip

b. S120 – BLE peripheral only protocol stack: s120_nrf51_2.1.0.zip

c. S130 – BLE concurrent peripheral/central/broadcaster/observer protocol stack: s130_nrf51_1.0.0.zip.

d. Extract all the files from this downloaded zip to a folder of your choice. One of the files extracted is the precompiled SD file with the “.hex” extension, which is the file that you will need to program into the nRF51 DK using the nRFgo Studio tool in the next step.

3.0 Programming the Softdevice on nRF51x22 on the DK

  1. Open the nRFgo Studio application
  2. Connect the RF51 DK board to the computer using a micro USB cable
  3. In the nRFgo Studio application the device should show up under the “nRF51 development boards” in the “Device Manager” window as shown circled in red in Figure 1. Click on this string, that starts with the word “Segger”, and the display in the big window on the right will change to display the flash memory map and programming options, as shown in Figure 1. NOTE: If you are prompted to update the Segger firmware on the nRF51 DK, click on "Yes" to upgrade to the latest Segger firmware. After the firmware upgrade the nRFgo Studio application may need to be restarted, as it may stop responding. Restart the applicaiton if so.
  4. Click on the “Erase all” button (circled in brown in Figure 1). After completion of this operation the memory map will show “Region 1 (Application)” with “Size: 256 kB”, as show in Figure 1.
  5. Next click on the “Program Softdevcie” tab on the right side of the memory map (circled in blue in Figure 1). Click “Browse” and locate the s110_nrf51_8.0.0_softdevice.hex file in the folder you previously unzipped to (or the equivalent hex file for S120 or S130, depending on which softdevice you downloaded).
  6. Click on the “Program” button. A small window should pop-up stating that the programming operation is in progress, and after successful completion of this, the big window in nRFgo Studio should look like the one in Figure 2.

image description Figure 1

image description Figure 2

The nRF51 DK is now ready to be programmed with a user application

4.0 Programming and Running a BLE Application on the nRF51 DK

  1. Navigate to the SDK example, “ble_app_hrs”, in the folder, “C:\Nordic Semiconductor\nRF51 SDK_v9.0.0\examples\ble_peripheral\ble_app_hrs”, and open the Keil project file “ble_app_hrs.uvmpw” by double-clicking on it. If you installed the Keil toolchain successfully in Section 1.0, Step 2b, above, the Keil IDE should open up and you should see a window as in Figure 3.
  2. The file, “ble_app_hrs.uvmpw”, is an Keil workspace file that contains several Keil projects as you can see from the list under “Workspace” in the "Project" window (circled in red outline in Figure 3).
  3. Next set the project “ble-app_hrs_s110_pca10028” as the active project, by right-clicking on it and selecting “Set as Active Project” in the context menu that pops-up. The active project will show up highlighted in dark grey as in Figure 3.
  4. Build the project by clicking on the "Build" icon, encircled in blue outline in Figure 3. The project should build with 0 errors and 0 warnings as show in the “Build Output” window, encircled in brown outline in Figure 3.
  5. Next, click on the "Load" icon, outlined in purple in Figure 3, to load the hex file into the flash of the nRF51 device on the DK. If the load is successful, LED1 will start blinking on the DK to indicate that ble_app_hrs application is running and advertising. If the load is successful, but LED1 does not blink, power cycle the nRF51 DK using the power switch on the board, or by disconnecting and reconnecting the micro USB cable from the board or the PC.

image description Figure 3

Flash Load Error: If there is a flash load error in step 5 above, it may be caused by incorrect memory setting in the Keil project. Click on the "Target Options" icon (outlined in orange in Figure 3), and ensure that the IROM1 and IRAM1 settings are as shown in Figure 4 below, changing the settings if needed. Click on "OK" to close the "Target Options" window, and click on the "Rebuild" icon, located to the immediate right of the "Build" icon, to rebuild the entire project.

image description Figure 4