Setting a new project
(After following the steps here)
Project Properties > XC8 global options > XC8 Compiler > Select ‘Optimizations’
Speed (or disable optimizations?) & Debug checkboxes
Set as needed (off and on is good for debugging)
Address qualifiers – CAN BE VERY IMPORTANT!!!!
If you are using anything that requires locating in specific memory locations set this to ‘Require’, e.g. variables used in assembler, etc. This is not the default setting as it can cause horribly confusing bugs until you realize it is the cause.
Operation mode
This is basically the optimization level setting and for debugging you are often going to want it set to ‘Free’ to effectively disable optimization even if you have a paid for version, so that you can breakpoint and step through code without any problems.
Project Properties > XC8 Global Options > XC8 Linker > Link in peripheral library: Yes (if you are using the old peripheral libraries)
Other things to consider
You may want to add the C99 typedefs to your project:
//----- STDINT.H TYPE DEFINITIONS -----
#ifndef uint8_t
typedef unsigned char uint8_t;
#endif
#ifndef int8_t
typedef signed char int8_t;
#endif
#ifndef uint16_t
typedef unsigned short uint16_t;
#endif
#ifndef int16_t
typedef signed short int16_t;
#endif
#ifndef uint32_t
typedef unsigned long uint32_t;
#endif
#ifndef int32_t
typedef signed long int32_t;
#endif
See this assembler issue here: https://ibex.tech/embedded/embedded-programming/microchip-pic/pic18/xc8-compiler/assembler-3
See this peripheral libraries issue here: https://ibex.tech/embedded/embedded-programming/microchip-pic/pic18/xc8-compiler/issues-xc8-compiler/xc8-peripheral-library-support-is-missing-for-the
If you get errors for interrupt function formatting etc double check you’ve got XC8 selected for the project and not C18!