Developing Nordic nRF51 Projects with Visual Studio

This tutorial shows how to create and debug a basic project for the Nordic nRF51-DK using Visual Studio. Before you begin, install VisualGDB 5.0 or later.

  1. Start Visual Studio and begin creating a new project using VisualGDB Embedded Project Wizard:![](http://visualgdb.com/w/wp-content/uploads/2015/08/nordic.png)
  2. Proceed with the default settings on the first page of the wizard:![](http://visualgdb.com/w/wp-content/uploads/2015/08/binary.png)
  3. On the next page of the wizard select the ARM toolchain. If you have not installed it yet, VisualGDB will install it automatically.![](http://visualgdb.com/w/wp-content/uploads/2015/08/armtoolchain.png)
  4. If you have not created Nordic projects before, click "Download Support for More Devices" and select the Nordic package in the list:![](http://visualgdb.com/w/wp-content/uploads/2015/08/nordicdev.png)
  5. Select your nRF51 device from the list and click "Next":![](http://visualgdb.com/w/wp-content/uploads/2015/08/devsel.png)
  6. On the "Sample" page of the wizard select the LEDBlink (BSP) sample and then select an evaluation board you are using from the list. This will automatically configure board-specific settings like LED locations. The board type is normally printed on a sticker on the board. E.g. for nRF51-DK, it is PCA10028. ![](http://visualgdb.com/w/wp-content/uploads/2015/08/sample.png)If you are not using a Nordic evaluation board, select the "LEDBlink" sample and specify the LED port number manually.
  7. Select a debug method compatible with your board. The nRF51-DK board comes with an on-board Segger J-Link device that can be used by selecting the "Segger J-Link" debug method and specifying the location of the Segger J-Link software package:![](http://visualgdb.com/w/wp-content/uploads/2015/08/jlink.png)If you don't have the Segger J-Link software installed, you can get it here.
  8. Press "Finish" to complete creating your project. Then build it via Build->Build Solution:![](http://visualgdb.com/w/wp-content/uploads/2015/08/build.png)
  9. Many of the functionality in Nordic projects is implemented using preprocessor macros. You can quickly expand a certain macro by right-clicking on it and selecting "Preprocess selected lines":![](http://visualgdb.com/w/wp-content/uploads/2015/08/lens1.png)
  10. Press F5 to load your program into the nRF51 chip and observe the LEDs. If you have selected the BSP-based sample, all LEDs on your board will turn on and off one after another:![](http://visualgdb.com/w/wp-content/uploads/2015/08/board.jpg)
  11. Set a breakpoint at the LEDS_INVERT() line and open the Debug->Windows->Hardware Registers. Then step over the LEDS_INVERT() line and observe how the GPIO register values change:![](http://visualgdb.com/w/wp-content/uploads/2015/08/hwreg.png)
  12. Press Shift-F5 to stop debugging. If you look in the Solution Explorer, you will notice that the project includes a lot of auxiliary code from the Nordic SDK. If you want to remove some of the code that is not used (or add other libraries such as various Bluetooth LE protocols), open VisualGDB Project Properties and go to the Embedded Frameworks page where you can select and customize the frameworks used by your project:![](http://visualgdb.com/w/wp-content/uploads/2015/08/frameworks.png)