• AVR Freaks

Hot!Writing ISR for the XC8 Compiler?

Author
arigead
Super Member
  • Total Posts : 408
  • Reward points : 0
  • Joined: 2011/02/07 06:58:31
  • Location: 0
  • Status: offline
2019/05/26 03:32:05 (permalink)
0

Writing ISR for the XC8 Compiler?

According to the documentation I've read including (https://microchipdeveloper.com/faq:31) I can write ISRs for the PIC18F45K40 with the simple 'interrupt' keyword. So something like:
 
void interrupt tc_int(void)
{
}

void interrupt low_priority tc_clr(void)
{
}

However the compiler doesn't actually accept that syntax, giving me:
 
error: variable has incomplete type 'void'
void interrupt low_priority tc_clr(void)
          ^
 
Can anybody suggest what the correct syntax if for writing an ISR for the XC8 Compiler?
 
Thanks for any help
#1

4 Replies Related Threads

    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: Writing ISR for the XC8 Compiler? 2019/05/26 05:37:08 (permalink)
    +2 (2)
    That is an old page, which refers to XC8 version 1.xx
    That error message means you are using the newer XC8 version 2.xx.
    The interrupt syntax has changed to make it more standards compliant.
    The correct syntax is in the User Manual that came with that compiler.
    Here's a hint: https://microchipdeveloper.com/xc8:whats-new-in-xc8-2-0
    and https://microchipdeveloper.com/xc8:moving-to-xc8-2-0
     
     
     

    Nearly there...
    #2
    1and0
    Access is Denied
    • Total Posts : 9495
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Writing ISR for the XC8 Compiler? 2019/05/26 12:32:54 (permalink)
    +3 (3)
    There are three user's guides located in the install folder of your XC8 compiler:  legacy PIC user's guide for v1.xx, newer PIC user's guide for v2.xx, and AVR user's guide.
    #3
    AndersG
    Senior Member
    • Total Posts : 174
    • Reward points : 0
    • Joined: 2008/08/05 04:51:24
    • Location: 0
    • Status: offline
    Re: Writing ISR for the XC8 Compiler? 2019/05/27 05:42:27 (permalink)
    +1 (1)
    This is an example ISR for Interrupt-On-Change taken from working code:
        // Init interrupt on change for PORTB.0 (DAV) PORTC.4 (ATN))
        PIE0bits.IOCIE = 1; // To allow individual port pins to generate an interrupt, the IOCIE bit of the PIE0 register must be set.
        IOCBNbits.IOCBN0 = 1; // Interrupt on negative-going edge DAV
        IOCBNbits.IOCBN4 = 1; // ATN negative going
        IOCBPbits.IOCBP4 = 1; // ATN positive going
        INTCONbits.GIE = 1; // Enable interrupts
        IPR0bits.IOCIP = 1; // Make interrupt on change high priority

    void __interrupt(high_priority) myHighIsr(void)
    {
        int i;
        // Check IOCBF for ATN
        //
        if(IOCBFbits.IOCBF4)
        {
     // Do stuff
            IOCBFbits.IOCBF4 = 0;
        }
        // Check IOCCF for DAV
        // State 0 - DAV went low
        if(IOCBFbits.IOCBF0)
        {
     // Do stuff
            IOCBFbits.IOCBF0 = 0;
        }
        PIR0bits.IOCIF = 0; // Clear interrupt on change flag

    }

    #4
    arigead
    Super Member
    • Total Posts : 408
    • Reward points : 0
    • Joined: 2011/02/07 06:58:31
    • Location: 0
    • Status: offline
    Re: Writing ISR for the XC8 Compiler? 2019/05/27 10:30:50 (permalink)
    +1 (1)
    Oops thanks everyone. Sorry about that found the wrong docs.
    #5
    Jump to:
    © 2019 APG vNext Commercial Version 4.5