{"id":756,"date":"2017-05-26T10:35:44","date_gmt":"2017-05-26T10:35:44","guid":{"rendered":"https:\/\/ibex.tech\/embedded\/?p=756"},"modified":"2024-08-12T15:18:20","modified_gmt":"2024-08-12T14:18:20","slug":"new-xc8-project","status":"publish","type":"post","link":"https:\/\/ibex.tech\/embedded\/microchip\/pic18\/xc8-compiler\/xc8-general\/new-xc8-project","title":{"rendered":".New XC8 Project"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">New XC8 Projects<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">Is your chosen PIC18 properly supported by XC8 V2 &amp; MCC?<\/h5>\n\n\n\n<p>You want it to be!<\/p>\n\n\n\n<p>The MCC release note lists the supported devices, under section \u201cSupported devices\u201d.<br>The Release Note is available on the MCC page (microchip.com\/mcc) &gt;&gt; Documentation &gt;&gt; For Current Release &gt;&gt; MCC Release Notes<\/p>\n\n\n\n<p>If its not then ideally select a PIC that is. Otherwise you will have to use an old version of MPLAB and XC8 V1 to be able to have the peripheral libraries. This is the response we we&#8217;re given by Microchip Support regarding this:<\/p>\n\n\n\n<p>Refer this MAPS webinar: https:\/\/www.youtube.com\/watch?v=lU4azxsfV00<\/p>\n\n\n\n<p>If your device is not supported , then you could use one of the devices supported by MCC to generate code for various peripherals, and then port this code to your device (Note: Porting code from one device to another device may require changes to the MCC generated code).<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Which XC8 Compiler Version?<\/h5>\n\n\n<p>XC8 V2.# and above<\/p>\n<p style=\"padding-left: 40px;\">You need to change to using the Microchip Code Configurator.<\/p>\n<p style=\"padding-left: 40px;\">Old peripheral libraries <a href=\"\/embedded-programming\/microchip-pic\/pic18\/xc8-compiler\/xc8-general\/peripheral-libraries-2\">can still be installed<\/a> in theory, although we ran into compile issues when we tried to use.\u00a0 Better to make the move to the new setup and code usage examples provided by the Microchip Code Configurator.<\/p>\n<p style=\"padding-left: 40px;\">Uses C99 by default which breaks various things.\u00a0 Its not very hard to <a href=\"\/embedded-programming\/microchip-pic\/pic18\/xc8-compiler\/xc8-general\/xc8-v2-compiler\">convert your code for C99<\/a>, or if you really want to you can set a V2 project to use C90 and avoid some of the changes needed.<\/p>\n<p>XC8 V1.#<\/p>\n<p style=\"padding-left: 40px;\">For old code projects it just works so why change from it.\u00a0 Moving to V2 will cause issues if using the now old unsupported microchip peripheral libraries.<\/p>\n<p style=\"padding-left: 40px;\">If you are used to V1.## and don&#8217;t need to use V2.## and want an easy life then you can of course just stay with V1, but you need to use an old version of MPLAB that supports it. From Microchip tech support:<\/p>\n\n\n<p>The legacy peripheral library is not recommend for new designs, since we are no longer supporting it or maintaining it.<\/p>\n\n\n\n<p>However, if you want to use the Legacy Plib you can install MPLAB X IDE v4.xx version from www.microchip.com\/archives and use MPLAB XC8 v1.34 compiler from this link: <a href=\"https:\/\/ww1.microchip.com\/downloads\/en\/DeviceDoc\/xc8-v1.34-full-install-windows-installer.exe\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/ww1.microchip.com\/downloads\/en\/DeviceDoc\/xc8-v1.34-full-install-windows-installer.exe<\/a><\/p>\n\n\n\n<p>Legacy Peripheral Library was removed in the following version of compiler: MPLAB XC8 v1.35<\/p>\n\n\n\n<p>We are focusing our efforts to develop and enhance the Microchip Code Configurator (MCC).<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Create MPLAB X Project<\/h4>\n\n\n\n<p>Run MPLAB X IDE<\/p>\n\n\n\n<p>Menu &gt; File &gt; New Project<\/p>\n\n\n\n<p>Categories: Microchip Embedded<\/p>\n\n\n\n<p>Projects: Standalone Project<\/p>\n\n\n\n<p>Select the device<\/p>\n\n\n\n<p>Select the debugging tool<\/p>\n\n\n\n<p>Select the Compiler to use<\/p>\n\n\n\n<p>Set project name and \u201cSet as main project\u201d<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Add Source Code Files<\/h4>\n\n\n\n<p>Add your initial project files to the projects \u201cProjectName.X\u201d directory.<\/p>\n\n\n\n<p>Right click the project &gt; Add Existing Item &gt; Select the files<\/p>\n\n\n\n<p>Drag them into the Header Files and Source File folders.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Setting Up Debug \/ Release Mode<\/h4>\n\n\n\n<p>Old MPLAB allowed you to use this macro in code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>__DEBUG<\/code><\/pre>\n\n\n\n<p>to detect if a debug or release mode was selected. It was just built in, but its not in MPLAB X.<\/p>\n\n\n\n<p>So add this to a global header file when debugging:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n#ifndef __DEBUG\n\t#define __DEBUG\t\t\t\t\t\t\/\/&lt;&lt;&lt;&lt;&lt; COMMENT OUT FOR RELEASE\n#endif\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Compiler Settings<\/h4>\n\n\n\n<p><em><strong>IMPORTANT \u2013 ENSURE YOU CHECK THE BASIC COMPILER SETUP OPTIONS TO HELP ENSURE YOU DON\u2019T GET CAUGHT UP IN STUPID BUGS<\/strong><\/em><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">New XC8 V1.## Projects<\/h4>\n\n\n\n<p>See our <a href=\"\/embedded\/microchip\/pic18\/xc8-compiler\/xc8-general\/xc8-v1-compiler\">page here<\/a>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">New XC8 V2 Projects<\/h4>\n\n\n\n<p>Converting Old Code to C99 for XC8 V2.00: <a href=\"\/embedded-programming\/microchip-pic\/pic18\/xc8-compiler\/xc8-general\/xc8-v2-compiler\">See our page here<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">MCC<\/h4>\n\n\n\n<p>Use the MPLAB Code Configurator to setup all your peripherals, uC settings etc.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">C90 \/ C99<\/h5>\n\n\n\n<p>C99 is new, breaks several old things (e.g. #asm).<\/p>\n\n\n<p>Select the one you want to use in:<\/p>\n<p style=\"padding-left: 40px;\">Project properties &gt; XC8 Global Options &gt; C standard<\/p>\n<p style=\"padding-left: 40px;\">Project properties &gt; XC8 Global Options &gt; XC8 linker &gt; Runtime &gt; Link in C library<\/p>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>New XC8 Projects Is your chosen PIC18 properly supported by XC8 V2 &amp; MCC? You want it to be! The MCC release note lists the supported devices, under section \u201cSupported devices\u201d.The Release Note is available on the MCC page (microchip.com\/mcc) &gt;&gt; Documentation &gt;&gt; For Current Release &gt;&gt; MCC Release Notes If its not then ideally [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[120,123,80],"tags":[],"class_list":["post-756","post","type-post","status-publish","format-standard","hentry","category-xc8-general-xc8-compiler-pic12","category-xc8-general-xc8-compiler-pic16","category-xc8-general"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/756","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/comments?post=756"}],"version-history":[{"count":28,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/756\/revisions"}],"predecessor-version":[{"id":1599,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/posts\/756\/revisions\/1599"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/media?parent=756"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/categories?post=756"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/embedded\/wp-json\/wp\/v2\/tags?post=756"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}