{"id":114,"date":"2014-07-10T20:04:21","date_gmt":"2014-07-10T20:04:21","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=114"},"modified":"2015-07-19T08:39:35","modified_gmt":"2015-07-19T15:39:35","slug":"arm-nxp_lpc","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/nxp_lpc\/","title":{"rendered":"Developing NXP LPC projects with Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to develop and debug a basic firmware project for the NXP LPC microcontrollers using Visual Studio and VisualGDB. We will use the LPCXpresso LPC1347 board modified to allow external SWD connections and the LPC-Link 2 programmer with Segger firmware.<\/p>\n<p><a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/cutboard.jpg\"><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/cutboard.jpg\" alt=\"cutboard\" width=\"200\" height=\"317\" \/><br \/>\n<\/a>The LPCXpresso boards can be cut into two in order to use the an external SWD interface such as LPC-Link 2, however instead of cutting the entire board we will simply disconnect the on-board LPC-Link 1 from the target and reuse its JTAG\/SWD connector.<\/p>\n<p>This is done by removing the level converters (U4,U5,U6 on most of the boards) and soldering together both terminals of R29 (normally it is not mounted). Once this modifications are done, the J5 connector can be used to attach an external programmer.<\/p>\n<p>Before we begin, ensure that <a href=\"\/download\">VisualGDB 4.1<\/a> or later is installed.<\/p>\n<ol>\n<li>Start Visual Studio. Begin creating a new project with the embedded project wizard: <a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/01-newprj.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/01-newprj.png\" alt=\"01-newprj\" width=\"700\" height=\"423\" \/><\/a><\/li>\n<li>Select &#8220;Embedded binary&#8221; on the first page:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/02-binary.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/02-binary.png\" alt=\"02-binary\" width=\"702\" height=\"571\" \/><\/a><\/li>\n<li>On the next page select the ARM toolchain. If it is not installed yet, VisualGDB will download and install it automatically:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/02a-arminstall.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/02a-arminstall.png\" alt=\"02a-arminstall\" width=\"701\" height=\"551\" \/><\/a><\/li>\n<li>\u00a0Then<br \/>\nclick &#8220;Download support for more devices&#8221; and select NXP LPC<br \/>\nin the list:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/03-nxp_lpc.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-5\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/03-nxp_lpc.png\" alt=\"03-nxp_lpc\" width=\"526\" height=\"279\" \/><\/a><\/li>\n<li>Select LPC1347 in the device list. Use the Filter field to find the right device faster:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/04-device.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/04-device.png\" alt=\"04-device\" width=\"702\" height=\"571\" \/><\/a><\/li>\n<li>When you press &#8220;Next&#8221;, VisualGDB will test the settings and ensure it can compile firmware for the device:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/05-test.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/05-test.png\" alt=\"05-test\" width=\"484\" height=\"294\" \/><\/a><\/li>\n<li>The next page allows customizing the sample project that will be created. If you are using the LPC1347 or LPC1200 board, keep the default settings. Otherwise, ensure that the LED port matches your board layout:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/06-blink.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-8\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/06-blink.png\" alt=\"06-blink\" width=\"702\" height=\"571\" \/><\/a><\/li>\n<li>The next page allows configuring the debug interface. There are several options for debugging the NXP LPC devices with VisualGDB:\n<ul>\n<li>Using Segger J-Link. It supports the NXP LPC devices out of the box.<\/li>\n<li>Using LPC-Link 2 debugger with Segger firmware. It is not as expensive as the stand-alone Segger J-Link, but would be sufficient for the most uses.<\/li>\n<li>Using some other debugger with OpenOCD. Note that OpenOCD does not support all families of the NXP LPC devices and may require manual script editing for those that are supported.<\/li>\n<\/ul>\n<p>We will use the LPC-Link 2 debugger with Segger firmware. First of all remove all jumpers from your LPC-Link 2, download the <a href=\"http:\/\/www.lpcware.com\/lpclink2-config-tool\"> LPC-Link 2 configuration tool<\/a> and the <a href=\"http:\/\/www.lpcware.com\/content\/nxpfile\/lpc18xx43xx-winusb-drivers-dfu-boot\"> LPC-Link 2 drivers<\/a>, ensure the drivers are installed, plug in your LPC-Link 2 and use the configuration tool to program the Segger firmware:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/07-segger.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-9\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/07-segger.png\" alt=\"07-segger\" width=\"700\" height=\"353\" \/><\/a><\/li>\n<li>\u00a0 Note that the configuration tool may fail<br \/>\nrandomly. You may need to try it several times until it<br \/>\nsucceeds or even use another computer:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/08-programmed.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/08-programmed.png\" alt=\"08-programmed\" width=\"700\" height=\"353\" \/><\/a><\/li>\n<li>Finally download and install the <a href=\"http:\/\/www.segger.com\/jlink-software.html\">Segger software package<\/a>. Connect the JP1 jumper on your LPC-Link, plug it in and ensure that it has the Segger driver installed:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/09-jlink.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-11\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/09-jlink.png\" alt=\"09-jlink\" width=\"545\" height=\"557\" \/><\/a><\/li>\n<li>Go back to VisualGDB project wizard, select Segger J-Link as the debug method and specify the path to the Segger software package. Ensure you enable the &#8220;reset device after programming&#8221; flag as it avoids several common problems with the interrupt controller:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/10-debugsettings.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-12\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/10-debugsettings.png\" alt=\"10-debugsettings\" width=\"702\" height=\"571\" \/><\/a><\/li>\n<li>Press &#8220;Finish&#8221; to generate your project. VisualGDB will use the new LPCOpen 2.x library to provide easier access to various LPC hardware. Press Ctrl-Shift-B to build your project:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/11-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-13\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/11-build.png\" alt=\"11-build\" width=\"698\" height=\"712\" \/><\/a><\/li>\n<li>Press F5 to start debugging. Note how the LED on the board is blinking:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/blink.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/blink.png\" alt=\"blink\" width=\"700\" height=\"404\" \/><\/a><\/li>\n<li>Set a breakpoint on a call to Delay(). It will be almost immediately hit. Step into it and use the normal debugging techniques to view the variable values:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/12-delay.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-15\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/tutorials\/arm\/nxp_lpc\/12-delay.png\" alt=\"12-delay\" width=\"701\" height=\"691\" \/><\/a><\/li>\n<li>Congratulations! You got your debugging to work. Press Shift-F5 to exit debugging session or select Debug-&gt;Detach All to remove all breakpoints and keep the firmware running in the background.<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to develop and debug a basic firmware project for the NXP LPC microcontrollers using Visual Studio<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[89],"tags":[53,58,59],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/114"}],"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=114"}],"version-history":[{"count":1,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/114\/revisions"}],"predecessor-version":[{"id":191,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/114\/revisions\/191"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=114"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=114"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=114"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}