{"id":277,"date":"2015-08-01T19:15:50","date_gmt":"2015-08-02T02:15:50","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=277"},"modified":"2015-08-26T20:43:47","modified_gmt":"2015-08-27T03:43:47","slug":"developing-nordic-nrf51-projects-with-visual-studio","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/nrf51\/","title":{"rendered":"Developing Nordic nRF51 Projects with Visual Studio"},"content":{"rendered":"<p>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.<\/p>\n<ol>\n<li>Start Visual Studio and begin creating a new project using VisualGDB Embedded Project Wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/nordic.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-286\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/nordic.png\" alt=\"nordic\" width=\"800\" height=\"570\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/nordic.png 800w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/nordic-300x214.png 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/li>\n<li>Proceed with the default settings on the first page of the wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/binary.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-287\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/binary.png\" alt=\"binary\" width=\"702\" height=\"571\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/binary.png 702w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/binary-300x244.png 300w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/a><\/li>\n<li>On the next page of the wizard select the ARM toolchain. If you have not installed it yet, VisualGDB will install it automatically.<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/armtoolchain.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-288\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/armtoolchain.png\" alt=\"armtoolchain\" width=\"702\" height=\"571\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/armtoolchain.png 702w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/armtoolchain-300x244.png 300w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/a><\/li>\n<li>If you have not created Nordic projects before, click &#8220;Download Support for More Devices&#8221; and select the Nordic package in the list:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/nordicdev.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-289\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/nordicdev.png\" alt=\"nordicdev\" width=\"584\" height=\"300\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/nordicdev.png 584w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/nordicdev-300x154.png 300w\" sizes=\"(max-width: 584px) 100vw, 584px\" \/><\/a><\/li>\n<li>Select your nRF51 device from the list and click &#8220;Next&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/devsel.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-290\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/devsel.png\" alt=\"devsel\" width=\"702\" height=\"659\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/devsel.png 702w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/devsel-300x282.png 300w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/a><\/li>\n<li>On the &#8220;Sample&#8221; 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.\u00a0<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/sample.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-291\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/sample.png\" alt=\"sample\" width=\"702\" height=\"659\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/sample.png 702w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/sample-300x282.png 300w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/a>If you are not using a Nordic evaluation board, select the &#8220;LEDBlink&#8221; sample and specify the LED port number manually.<\/li>\n<li>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 &#8220;Segger J-Link&#8221; debug method and specifying the location of the Segger J-Link software package:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/jlink.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-292\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/jlink.png\" alt=\"jlink\" width=\"702\" height=\"659\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/jlink.png 702w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/jlink-300x282.png 300w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/a>If you don&#8217;t have the Segger J-Link software installed, you can get it <a href=\"https:\/\/www.segger.com\/jlink-software.html\">here<\/a>.<\/li>\n<li>Press &#8220;Finish&#8221; to complete creating your project. Then build it via Build-&gt;Build Solution:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-293\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/build.png\" alt=\"build\" width=\"695\" height=\"606\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/build.png 695w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/build-300x262.png 300w\" sizes=\"(max-width: 695px) 100vw, 695px\" \/><\/a><\/li>\n<li>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 &#8220;Preprocess selected lines&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/lens1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-295\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/lens1.png\" alt=\"lens\" width=\"695\" height=\"605\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/lens1.png 695w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/lens1-300x261.png 300w\" sizes=\"(max-width: 695px) 100vw, 695px\" \/><\/a><\/li>\n<li>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:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/board.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-296\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/board.jpg\" alt=\"board\" width=\"700\" height=\"359\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/board.jpg 700w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/board-300x154.jpg 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/a><\/li>\n<li>Set a breakpoint at the LEDS_INVERT() line and open the Debug-&gt;Windows-&gt;Hardware Registers. Then step over the LEDS_INVERT() line and observe how the GPIO register values change:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/hwreg.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-297\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/hwreg.png\" alt=\"hwreg\" width=\"695\" height=\"605\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/hwreg.png 695w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/hwreg-300x261.png 300w\" sizes=\"(max-width: 695px) 100vw, 695px\" \/><\/a><\/li>\n<li>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:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/frameworks.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-298\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/frameworks.png\" alt=\"frameworks\" width=\"727\" height=\"733\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/frameworks.png 727w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/frameworks-150x150.png 150w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/08\/frameworks-298x300.png 298w\" sizes=\"(max-width: 727px) 100vw, 727px\" \/><\/a>Now that you have created a basic project, you can follow <a href=\"http:\/\/visualgdb.com\/tutorials\/arm\/nrf51\/mouse\">this tutorial<\/a> to create and debug a Bluetooth LE-based mouse.<\/li>\n<\/ol>\n<p>We would like to thank Maik Engelhardt for contributing the initial version of the Nordic BSP.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to create and debug a basic project for the Nordic nRF51-DK using Visual Studio. Before you<\/p>\n","protected":false},"author":1,"featured_media":300,"comment_status":"closed","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"footnotes":""},"categories":[89],"tags":[53,64,95],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/277"}],"collection":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/comments?post=277"}],"version-history":[{"count":6,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/277\/revisions"}],"predecessor-version":[{"id":525,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/277\/revisions\/525"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media\/300"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}