Electronic – XC8 Interrupt function qualifier

cmicrochipxc8

Referring to the XC8 user manual, DS50002053E, section 2.5.10.3 the following is stated:

For 8-bit compilers, change any occurrence of the interrupt qualifier
e.g., from:

void interrupt low_priority myLoIsr (void)

to the following:

void __interrupt(low_priority) myLoIsr(void)

Here's a simple piece of code I wrote:

void __interrupt(high_priority) isr_high (void)
{
    // IFC
    if(INTCON3bits.INT2IF)
    {
        TMR0 = TMR1 = timerZero;    // Reset the IFA and IFB counts
        ++ifc;
        ifa = ifb = 0;
        LATEbits.LATE0 ^= 1;
        INTCON3bits.INT2IF = 0;
    }
}

And here is a piece of sample code that the XC8 manual offers in section 2.5.10.1:

__interrupt(low_priority) void getData (void){

    if(TMR0IE && TMR0IF) {
        TMR0IF = 0;
        ++tick_count;
    } 
}

Unfortunately I cannot get the code to compile. Here are some relevant compiler errors:

(908) exit status = 1
Minion.c:215: error: (285) no identifier in declaration
make2:
[build/default/production/Minion.p1] Error 1
make1: *
[.build-conf] Error 2
Minion.c:215: error: (1275) only functions may be qualified "interrupt"
make: *** [.build-impl] Error 2
Minion.c:215: error: (372) "," expected
Minion.c:216: error: (314) ";" expected*

Now, the manual is a little bit ambiguous because the section example in 2.5.10.1 shows the interrupt function identifier 'void' immediately prior to the function name, where as section 2.5.10.3 shows the void identifier immediately prior to __interrupt. However, I have tried it both ways with no joy.

Someone else asked the same question here, but it was never answered to the OPs satisfaction or mine.

If someone has worked out the proper syntax for this, I would appreciate a share! If nobody is able to answer I will go back to the method I know works, which is shown in section 5.9.1 of the manual.

Best Answer

You need to make sure you have checked the Use CCI Syntax option and you have #include <xc.h> in all source files.

All noted in section 2.3 of the same manual.

UseCCI