2
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Just a sanity check, you have checked the Use CCI Syntax option and you have included <xc.h> have you? All noted in section 2.3 of the same manual. \$\endgroup\$ – Roger Rowland May 6 '15 at 9:35
  • \$\begingroup\$ That sounds interesting. I have of course included xc.h (otherwise I'd have other problems) but I wasn't aware of an option to use CCI syntax which must be checked. Will look for it and get back to you! \$\endgroup\$ – Brian J Hoskins May 6 '15 at 9:38
  • \$\begingroup\$ Okay that was indeed the answer! Thanks very much for the information. I'm disappointed it turns out to be something simple on the one hand, but on the other hand at least I can go forward with this understanding. Do you want to post this as an answer which I will accept? \$\endgroup\$ – Brian J Hoskins May 6 '15 at 9:39
  • \$\begingroup\$ Ok, answer posted, glad you're sorted now. \$\endgroup\$ – Roger Rowland May 6 '15 at 9:54
4
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ I had neglected section 2.3 of the manual which does indeed state that CCI syntax must be enabled. Thank you for the simple answer! \$\endgroup\$ – Brian J Hoskins May 6 '15 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.