{"id":1256,"date":"2016-01-11T18:48:33","date_gmt":"2016-01-12T02:48:33","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=1256"},"modified":"2016-01-12T07:43:46","modified_gmt":"2016-01-12T15:43:46","slug":"developing-nordic-nrf52-code-with-visual-studio","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/nrf51\/nrf52\/","title":{"rendered":"Developing Nordic nRF52 code with Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to develop and debug a basic firmware for the nRF52 devices with Visual Studio and VisualGDB.<\/p>\n<ol>\n<li>Start Visual Studio and select File-&gt;New Project. Then choose the VisualGDB Embedded Project Wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/01-prj2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1257\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/01-prj2.png\" alt=\"01-prj\" width=\"786\" height=\"463\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/01-prj2.png 786w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/01-prj2-300x177.png 300w\" sizes=\"(max-width: 786px) 100vw, 786px\" \/><\/a><\/li>\n<li>Proceed with the default &#8220;Create a new project setting&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/02-bin.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1258\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/02-bin.png\" alt=\"02-bin\" width=\"688\" height=\"565\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/02-bin.png 688w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/02-bin-300x246.png 300w\" sizes=\"(max-width: 688px) 100vw, 688px\" \/><\/a><\/li>\n<li>Select the nRF52 device from the list. If you have not downloaded the nRF52 BSP yet, click &#8220;Download support for more devices&#8221;. If you are using VisualGDB 5.1 or later, the device will always appear in the list and the BSP will be downloaded once you select it:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/03-getdev.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1259\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/03-getdev.png\" alt=\"03-getdev\" width=\"769\" height=\"563\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/03-getdev.png 769w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/03-getdev-300x220.png 300w\" sizes=\"(max-width: 769px) 100vw, 769px\" \/><\/a><\/li>\n<li>If you are using a preview version of the nRF52 device, select 32KB in the &#8220;RAM size&#8221; field (the second 32KB are placed to an incorrect address as described <a href=\"https:\/\/devzone.nordicsemi.com\/question\/42020\/nrf52-dk-ram-for-samples\/\">here<\/a>, making them inaccessible unless a separate code\/data section is used), otherwise select 64KB: <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/04-nrf52.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1260\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/04-nrf52.png\" alt=\"04-nrf52\" width=\"772\" height=\"749\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/04-nrf52.png 772w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/04-nrf52-300x291.png 300w\" sizes=\"(max-width: 772px) 100vw, 772px\" \/><\/a><\/li>\n<li>Select a sample from the sample list. In this example we will build the simplest LEDBlink sample, however you can select a different one and follow one of our <a href=\"http:\/\/visualgdb.com\/w\/tutorials\/tag\/nrf51\/\">nRF51 tutorials<\/a> to see Bluetooth LE functionality in action. If you are using nRF52-DK, select the PCA10036 board:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/05-sample.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1261\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/05-sample.png\" alt=\"05-sample\" width=\"688\" height=\"565\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/05-sample.png 688w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/05-sample-300x246.png 300w\" sizes=\"(max-width: 688px) 100vw, 688px\" \/><\/a><\/li>\n<li>Select Segger J-Link as the debug method. Ensure you check the &#8220;Reset device after programming&#8221; checkbox:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/06-debug1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1262\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/06-debug1.png\" alt=\"06-debug\" width=\"688\" height=\"565\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/06-debug1.png 688w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/06-debug1-300x246.png 300w\" sizes=\"(max-width: 688px) 100vw, 688px\" \/><\/a><\/li>\n<li>Press &#8220;Finish&#8221; to create the project. Build it by pressing Ctrl-Shift-B:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/07-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1263\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/07-build.png\" alt=\"07-build\" width=\"802\" height=\"580\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/07-build.png 802w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/07-build-300x217.png 300w\" sizes=\"(max-width: 802px) 100vw, 802px\" \/><\/a><\/li>\n<li>Connect your board to the USB port and press F5 to begin debugging. Observe how the 4 LEDs start blinking:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/board1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1266\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/board1.jpg\" alt=\"board\" width=\"700\" height=\"340\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/board1.jpg 700w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/board1-300x146.jpg 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/a><\/li>\n<li>Set a breakpoint on the LEDS_INVERT() line. Once the breakpoint is triggered, you can hover your mouse over different variables to see their values, step through the code or use the Hardware Registers window to explore the state of the hardware registers:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/08-watch.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1264\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/08-watch.png\" alt=\"08-watch\" width=\"802\" height=\"580\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/08-watch.png 802w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2015\/12\/08-watch-300x217.png 300w\" sizes=\"(max-width: 802px) 100vw, 802px\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to develop and debug a basic firmware for the nRF52 devices with Visual Studio and VisualGDB.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[89,18],"tags":[53,95],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1256"}],"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=1256"}],"version-history":[{"count":1,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1256\/revisions"}],"predecessor-version":[{"id":1267,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1256\/revisions\/1267"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=1256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=1256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=1256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}