New XC8 Projects

Which XC8 Compiler Version?

XC8 V2.##

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…

New XC8 V2 Projects

Converting Old Code to C99 for XC8 V2.00

See our page here

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

New XC8 V1.## Projects

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:

#ifndef uint8_t
typedef unsigned char uint8_t;

#ifndef int8_t
typedef signed char int8_t;

#ifndef uint16_t
typedef unsigned short uint16_t;

#ifndef int16_t
typedef signed short int16_t;

#ifndef uint32_t
typedef unsigned long uint32_t;

#ifndef int32_t
typedef signed long int32_t;

See this:

See this assembler issue here:

See this peripheral libraries issue here:

If you get errors for interrupt function formatting etc double check you’ve got XC8 selected for the project and not C18!

We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.


Your email address will not be published.