Electronic – Deciding which compiler for PIC18F26K22 in MPLAB X, C18 or XC8

c18mplabmplabxpicxc8

I'm trying to program a microprocessor for the first time, and having lots and lots of doubts.

I have installed both the C18 and the XC8 compilers, plus a few others. When I create a new project and select my microprocessor, PIC18F26K22, I get to choose between these two compilers, in addition to the two mpasm assemblers. When they are both available to choose, does that mean that they both work?

How do I decide which one to use? I have tried googling but cant seem to find the answer; perhaps because I don't know what to google for and don't know how to read the results. Or perhaps it makes no real difference which one I pick?

Best Answer

As Roger says, use XC8. It's the newer compiler.

The C18 compiler is obsolete and it won't support any newer devices.

Another disadvantage of C18 is that it only supports the PIC18 family of microcontrollers as opposed to the XC8, which supports all the 8-bit PIC microcontrollers: PIC10, PIC12, PIC16, PIC18.


I'd also argue that XC8 (which is based on the HI-TECH C Compiler) is a tad easier to use than C18. Just take a look at how you would declare an ISR in both compilers:

C18:

void isr(void)
{
   /* ... */
}

#pragma code high_vector=0x08

void interrupt_at_high_vector(void)
{
    _asm GOTO isr _endasm
}

#pragma code

#pragma interrupt isr

vs XC8:

void interrupt isr(void)
{
   /* ... */
}