{"id":1832,"date":"2016-04-06T19:36:20","date_gmt":"2016-04-07T02:36:20","guid":{"rendered":"http:\/\/visualgdb.com\/w\/?p=1832"},"modified":"2016-04-06T19:37:31","modified_gmt":"2016-04-07T02:37:31","slug":"developing-firmware-for-infineon-xmc-devices-with-visual-studio","status":"publish","type":"post","link":"https:\/\/visualgdb.com\/tutorials\/arm\/infineon\/","title":{"rendered":"Developing Firmware for Infineon XMC Devices with Visual Studio"},"content":{"rendered":"<p>This tutorial shows how to develop firmware for the Infineon XMC devices with Visual Studio and VisualGDB. Before you begin, install <a href=\"http:\/\/visualgdb.com\/download\/\">VisualGDB<\/a>.<\/p>\n<ol>\n<li>Start Visual Studio and open the VisualGDB Embedded Project Wizard:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/01-prjname.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1833\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/01-prjname.png\" alt=\"01-prjname\" width=\"816\" height=\"483\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/01-prjname.png 816w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/01-prjname-300x178.png 300w\" sizes=\"(max-width: 816px) 100vw, 816px\" \/><\/a><\/li>\n<li>On the first page select &#8220;Create a new project -&gt; Embedded Binary&#8221;:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/02-bin.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1834\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/02-bin.png\" alt=\"02-bin\" width=\"738\" height=\"565\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/02-bin.png 738w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/02-bin-300x230.png 300w\" sizes=\"(max-width: 738px) 100vw, 738px\" \/><\/a><\/li>\n<li>On the Device Selection page select the ARM toolchain (if it&#8217;s not installed, VisualGDB will install it automatically). Then choose your Infineon device from the list. In this example we will use the <a href=\"http:\/\/www.infineon.com\/cms\/en\/product\/evaluation-boards\/KIT_XMC12_BOOT_001\/productType.html?productType=db3a30443ba77cfd013baec9c1cc0ca7\">XMC1200 Boot Kit<\/a>, so we select the XMC1200-0200 device. if this is the first time you are creating a project for Infineon devices, VisualGDB will automatically download and install the necessary library files:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/03-getdev.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1835\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/03-getdev.png\" alt=\"03-getdev\" width=\"737\" height=\"565\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/03-getdev.png 737w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/03-getdev-300x230.png 300w\" sizes=\"(max-width: 737px) 100vw, 737px\" \/><\/a><\/li>\n<li>Once the files are downloaded and the device is shown in the list, press &#8220;Next&#8221; to go to the sample selection page:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/04-dev.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1836\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/04-dev.png\" alt=\"04-dev\" width=\"738\" height=\"565\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/04-dev.png 738w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/04-dev-300x230.png 300w\" sizes=\"(max-width: 738px) 100vw, 738px\" \/><\/a><\/li>\n<li>On the Sample Selection page select the port and pin where your LED is connected. On the XMC1200 Boot Kit there are 5 LEDs connected to ports P0_0, P0_2, P0_5, P0_6 and P0_7. We will usethe P0_6 port in this example:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/05-blink.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1837\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/05-blink.png\" alt=\"05-blink\" width=\"738\" height=\"565\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/05-blink.png 738w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/05-blink-300x230.png 300w\" sizes=\"(max-width: 738px) 100vw, 738px\" \/><\/a><\/li>\n<li>The Infineon development boards come with on-board Segger J-Link, so we will select &#8220;Segger J-Link&#8221; as the debug method. VisualGDB will automatically configure the J-Link software based on your device type:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/06-segger.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1838\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/06-segger.png\" alt=\"06-segger\" width=\"738\" height=\"578\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/06-segger.png 738w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/06-segger-300x235.png 300w\" sizes=\"(max-width: 738px) 100vw, 738px\" \/><\/a>If you don&#8217;t have the J-Link software installed, you can download it from the <a href=\"https:\/\/www.segger.com\/jlink-software.html\">Segger website<\/a>.<\/li>\n<li>Press &#8220;Finish&#8221; to generate your project. Once it is generated, you can build it via Build-&gt;Build Solution. Note how VisualGDB displays the memory utilization at the end of the build log:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/07-build.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1839\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/07-build.png\" alt=\"07-build\" width=\"925\" height=\"678\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/07-build.png 925w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/07-build-300x220.png 300w\" sizes=\"(max-width: 925px) 100vw, 925px\" \/><\/a><\/li>\n<li>Press F5 to start debugging note how the red LED on the board marked with P06 will start blinking:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/ledon.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1862\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/ledon.jpg\" alt=\"ledon\" width=\"700\" height=\"516\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/ledon.jpg 700w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/ledon-300x221.jpg 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/a><\/li>\n<li>Set a breakpoint in the SysTick_Handler() function in the main file. Once it triggers, you can use the Hardware Registers window to quickly find the registers like PORT0_OUT and examine the state of the hardware:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/08-reg1.png\"> <img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1840\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/08-reg1.png\" alt=\"08-reg1\" width=\"925\" height=\"678\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/08-reg1.png 925w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/08-reg1-300x220.png 300w\" sizes=\"(max-width: 925px) 100vw, 925px\" \/><\/a><\/li>\n<li>Step over the XMC_GPIO_ToggleOutput() function. Note how the LED state changes:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/ledoff.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1864\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/ledoff.jpg\" alt=\"ledoff\" width=\"700\" height=\"494\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/ledoff.jpg 700w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/ledoff-300x212.jpg 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/a><\/li>\n<li>The value of the OUT register will change accordingly:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/09-reg2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1841\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/09-reg2.png\" alt=\"09-reg2\" width=\"925\" height=\"678\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/09-reg2.png 925w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/09-reg2-300x220.png 300w\" sizes=\"(max-width: 925px) 100vw, 925px\" \/><\/a><\/li>\n<li>Once important concept worth mentioning is the way XMC1xxx devices handle interrupts. The Cortex-M0 core expects the interrupt vector table to be located at address 0x00000000, however the XMC1xxx devices don&#8217;t have neither RAM nor FLASH mapped there. Instead, the 0x00000000 address contains a constant handler table that expects the first handler to be at address 0x20000000 (start of RAM), the next one at 0x20000004 and\u00a0 so on. The startup code from Infineon examples includes special code fragments called interrupt veneers that are placed at the beginning of RAM and jump to the actual interrupt handlers. VisualGDB startup code uses a similar technique: at startup time it copies the interrupt vector table from FLASH into RAM and generates interrupt veneers that jump to the handlers referenced in the copied table:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/10-veneers.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1842\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/10-veneers.png\" alt=\"10-veneers\" width=\"925\" height=\"678\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/10-veneers.png 925w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/10-veneers-300x220.png 300w\" sizes=\"(max-width: 925px) 100vw, 925px\" \/><\/a><\/li>\n<li>You can explore the veneers by opening the Disassembly view and going to address 0x20000000. You will see that each veneer loads the target address from a subsequent entry in the table. The table contents can be conveniently viewed as a set of addresses via the GDB&#8217;s &#8220;x&#8221; command:\n<pre class=\"\">x\/30a &lt;start address&gt;<\/pre>\n<p>The command will display the next 30 entries at given address and annotate them with the symbol names. Note that most interrupt handlers default to the Default_handler as they are not defined anywhere in the code:<a href=\"http:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/11-handlers.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1843\" src=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/11-handlers.png\" alt=\"11-handlers\" width=\"925\" height=\"678\" srcset=\"https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/11-handlers.png 925w, https:\/\/visualgdb.com\/w\/wp-content\/uploads\/2016\/04\/11-handlers-300x220.png 300w\" sizes=\"(max-width: 925px) 100vw, 925px\" \/><\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to develop firmware for the Infineon XMC devices with Visual Studio and VisualGDB. Before you begin,<\/p>\n","protected":false},"author":1,"featured_media":1863,"comment_status":"closed","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"footnotes":""},"categories":[89],"tags":[53,127,59],"_links":{"self":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1832"}],"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=1832"}],"version-history":[{"count":1,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1832\/revisions"}],"predecessor-version":[{"id":1865,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/posts\/1832\/revisions\/1865"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media\/1863"}],"wp:attachment":[{"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/media?parent=1832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/categories?post=1832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/visualgdb.com\/w\/wp-json\/wp\/v2\/tags?post=1832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}