{"id":7732,"date":"2022-01-12T08:27:28","date_gmt":"2022-01-12T16:27:28","guid":{"rendered":"https:\/\/visualgdb.com\/w\/?p=7732"},"modified":"2022-01-12T08:27:28","modified_gmt":"2022-01-12T16:27:28","slug":"developing-pic32-projects-with-visualgdb","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/pic32\/","title":{"rendered":"Developing PIC32 Projects with VisualGDB"},"content":{"rendered":"<p>This tutorial shows how to create, build and debug applications for the PIC32 devices with Visual Studio and VisualGDB.<\/p>\n<p>Before you begin, make sure you install <a href=\"https:\/\/www.microchip.com\/en-us\/development-tools-tools-and-software\/mplab-x-ide\">MPLAB X<\/a> (that includes the PIC32 compiler) and VisualGDB 5.6 or later. Then, connect the following signals on your chip to your JTAG debugger:<\/p>\n<table style=\"border-collapse: collapse; width: 64%;\" border=\"1\">\n<tbody>\n<tr>\n<td style=\"width: 20%;\">Signal<\/td>\n<td style=\"width: 20%;\">JTAG20 Pin<\/td>\n<td style=\"width: 20%;\">Pin on PIC32MX534F064H<\/td>\n<td style=\"width: 20%;\">Pin on PIC32MM256GPM064<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 20%;\">TDI<\/td>\n<td style=\"width: 20%;\">5<\/td>\n<td style=\"width: 20%;\">B13<\/td>\n<td style=\"width: 20%;\">RB3<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 20%;\">TDO<\/td>\n<td style=\"width: 20%;\">13<\/td>\n<td style=\"width: 20%;\">B11<\/td>\n<td style=\"width: 20%;\">RC9<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 20%;\">TMS<\/td>\n<td style=\"width: 20%;\">7<\/td>\n<td style=\"width: 20%;\">B10<\/td>\n<td style=\"width: 20%;\">RB9<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 20%;\">TCK<\/td>\n<td style=\"width: 20%;\">9<\/td>\n<td style=\"width: 20%;\">B12<\/td>\n<td style=\"width: 20%;\">RB8<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 20%;\">RESET<\/td>\n<td style=\"width: 20%;\">3<\/td>\n<td style=\"width: 20%;\">MCLR#<\/td>\n<td style=\"width: 20%;\">MCLR#<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<ol>\n<li>Start Visual Studio and open the VisualGDB Embedded Project Wizard:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/01-newprj-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7733\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/01-newprj-3.png\" alt=\"\" width=\"1024\" height=\"680\" \/><\/a><\/li>\n<li>Enter the name and location for your project:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/02-name-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7734\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/02-name-1.png\" alt=\"\" width=\"1024\" height=\"680\" \/><\/a><\/li>\n<li>Select &#8220;Create a new project -&gt; Embedded Application&#8221; and pick the build system you would like to use. We recommend Advanced CMake or MSBuild for most scenarios:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/03-cmake.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7735\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/03-cmake.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>On the next page locate your PIC32 toolchain. VisualGDB can automatically detect the PIC32 compiler from the MPLAB X via registry. If it doesn&#8217;t appear in the toolchain list, check the\u00a0 <strong>C:\\Program Files (x86)\\Sysprogs\\VisualGDB\\Rules\\KnownToolchains.xml <\/strong>file for the exact registry key used by VisualGDB to find it:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/04-pic32.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7736\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/04-pic32.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>Once you select the PIC32 compiler, VisualGDB will display the list of supported devices. Pick your device and click &#8220;Install&#8221; to download the corresponding BSP: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/05-getmx.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7737\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/05-getmx.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>Once the BSP is installed, press &#8220;Next&#8221; to proceed to the next page: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/06-gotmx.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7738\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/06-gotmx.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>Select the &#8220;Blink&#8221; sample project and click &#8220;Next&#8221;: <a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/07-port.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7739\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/07-port.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a>You can optionally set the LED port to match your board pinout, or just proceed with the default settings if you plan to replace the <strong>main()<\/strong> contents with something else.<\/li>\n<li>On the last page of the wizard select your debug method. As of November 2021, VisualGDB supports the following methods for PIC32:<br \/>\n<table style=\"border-collapse: collapse; width: 100%;\" border=\"1\">\n<tbody>\n<tr>\n<td style=\"width: 33.3333%;\">Debug Method<\/td>\n<td style=\"width: 33.3333%;\">Supported Devices<\/td>\n<td style=\"width: 33.3333%;\">Remarks<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%;\">Segger J-Link<\/td>\n<td style=\"width: 33.3333%;\">Most PIC32MX devices<\/td>\n<td style=\"width: 33.3333%;\">Works out-of-the-box, requires Segger J-Link hardware. Supported by Segger.<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 33.3333%;\">OpenOCD<\/td>\n<td style=\"width: 33.3333%;\">PIC32MX, PIC32MM<\/td>\n<td style=\"width: 33.3333%;\">Open-source tool without technical support. Works with most JTAG debuggers, however the PIC32MX support is somewhat unreliable (PIC32MM support is better). May require extra troubleshooting\/patching.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/08-segger.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7740\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/08-segger.png\" alt=\"\" width=\"886\" height=\"693\" \/><\/a><\/li>\n<li>Press &#8220;Finish&#8221; to generate the project. Build it by pressing Ctrl-Shift-B. Note how VisualGDB automatically picks up the memory layout from the device definition, and shows the memory utilization:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/09-built.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7741\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/09-built.png\" alt=\"\" width=\"1427\" height=\"912\" \/><\/a><\/li>\n<li>Set a breakpoint before a call to Delay() and press F5 to begin debugging. The breakpoint will trigger, allowing you to evaluate variables and view the hardware registers:<a href=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/10-bkpt.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7742\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2021\/11\/10-bkpt.png\" alt=\"\" width=\"1427\" height=\"912\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to create, build and debug applications for the PIC32 devices with Visual Studio and VisualGDB. Before<\/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":[243],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7732"}],"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=7732"}],"version-history":[{"count":1,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7732\/revisions"}],"predecessor-version":[{"id":7743,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/7732\/revisions\/7743"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=7732"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=7732"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=7732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}