Use MCC
Get over it, you have to with V4.# and above XC32, all the old plib.h and config etc functions are completely gone. If you don’t want it you’ll have to use V2.# of the XC32 compiler (we skipped V3.#, not sure on that one).
Create MPLAB X Project
Run MPLAB X IDE
Menu > File > New Project
Project Type (Standalone or Harmony)
Categories: Microchip Embedded
Projects:
Standalone Project
The typical straightforward project choice.
(Don’t use if you are going to be using Harmony libraries, or if only “MPLAB Harmony” is available for your device within MCC once you create the project and run MCC the first time – in this case you MUST create your project as a “32-bit MCC Harmony Project”. If you select “Standalone Project” and MCC Harmony you’ll get a confusing corrupt config error when you try and use MCC).
Harmony Project
Must be used if you are going to be using Harmony libraries, or if only “MPLAB Harmony” is available for your device within MCC once you create the project and run MCC the first time
Select the device
Select the debugging tool
Select the Compiler to use
Set project name and “Set as main project”
MCC
Use the MPLAB Code Configurator to setup all your peripherals, uC settings etc.
Add Source Code Files
Add your initial project files to the projects “ProjectName.X” directory (not the “/firmware/src/” directory that has the main.c in it)
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
Right click project > Project Properties > Conf > XC32 > xc32-gcc
Check these settings in particular:
Right click project > Project Properties > Conf > XC32 > xc32-gcc > Preprocessing and messages > Make warnings into errors = No
Right click project > Project Properties > Conf > XC32 > xc32-gcc > Optimization > optimization-level: 0 <<<For simple degugging
MCC Config
Make sure you use the MCC clock setup to configure clock source, speed etc. See here.