New XC8 Projects
Which XC8 Compiler Version?
XC8 V2.# and above
You need to change to using the Microchip Code Configurator.
Old peripheral libraries can still be installed in theory, although we ran into compile issues when we tried to use. Better to make the move to the new setup and code usage examples provided by the Microchip Code Configurator.
Uses C99 by default which breaks various things. Its not very hard to convert your code for C99, or if you really want to you can set a V2 project to use C90 and avoid some of the changes needed.
XC8 V1.#
For old code projects it just works so why change from it. Moving to V2 will cause issues if using the now old microchip peripheral libraries.
If you are used to V1.## and don’t need to use V2.## and want an easy life then you can of course just stay with V1, but V2 is the future man…
Create MPLAB X Project
Run MPLAB X IDE
Menu > File > New Project
Categories: Microchip Embedded
Projects: Standalone Project
Select the device
Select the debugging tool
Select the Compiler to use
Set project name and “Set as main project”
Add Source Code Files
Add your initial project files to the projects “ProjectName.X” directory.
Right click the project > Add Existing Item > Select the files
Drag them into the Header Files and Source File folders.
Setting Up Debug / Release Mode
Old MPLAB allowed you to use this macro in code:
__DEBUG
to detect if a debug or release mode was selected. It was just built in, but its not in MPLAB X.
So add this to a global header file when debugging:
#ifndef __DEBUG
#define __DEBUG //<<<<< COMMENT OUT FOR RELEASE
#endif
Compiler Settings
IMPORTANT – ENSURE YOU CHECK THE BASIC COMPILER SETUP OPTIONS TO HELP ENSURE YOU DON’T GET CAUGHT UP IN STUPID BUGS
New XC8 V1.## Projects
See our page here.
New XC8 V2 Projects
Converting Old Code to C99 for XC8 V2.00: See our page here
MCC
Use the MPLAB Code Configurator to setup all your peripherals, uC settings etc.
C90 / C99
C99 is new, breaks several old things (e.g. #asm).
Select the one you want to use in:
Project properties > XC8 Global Options > C standard
Project properties > XC8 Global Options > XC8 linker > Runtime > Link in C library