• AVR Freaks

Hot!Compiling Error with interrupt service routines for ATtiny using xc8

Author
XPModder
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2020/07/10 02:28:39
  • Location: 0
  • Status: offline
2020/08/01 01:35:41 (permalink)
0

Compiling Error with interrupt service routines for ATtiny using xc8

Hello,
I am working on a project using an ATtiny 202 and I am nearly done with my programming, but I have run into a large problem. I can't create any ISRs, because I always get a compiler error.
I am using the newest version of MPLABX IDE (5.35) and the second newest version of the xc8 compiler (v2.10). I cannot use the newest version of the compiler, because that is for some reason missing the device header for the ATtiny 202. (I had a different thread about that problem on Stackoverflow a while ago)
I have created the ISRs exactly like described in the XC8 Manual, and the IDE doesn't mark it as a problem either, but when I then try to compile the program I always get a compiler error. Here is one of my ISRs:
void __interrupt (RTC_PIT_vect_num) pit_int(void){

onPIT(); //Run the function
RTC.PITINTFLAGS = 0x0; //and clear the interrupt flags

}
The IDE marks the RTC_PIT_vect_num blue and correctly recognizes it, as it is defined in the device header.
When I try to compile it, I get this error message, and the build fails:
main.c:864:19: error: expected declaration specifiers or '...' before numeric constant
void __interrupt (RTC_PIT_vect_num) pit_int(void){
^
I dont know what exactly the problem is and how to solve it.
For comparison, here is an example from the "XC8 User Guide for AVR", page 83:
void __interrupt(SPI_STC_vect_num) spi_Isr(void) {
process(SPI_SlaveReceive());
return;
}
As you can see, the structure of the function is exactly the same as in my own ISR.
Does someone have an idea what the problem is or may be and how to fix it?
 
 
Should anyone ask: Yes I have posted this question on Stackoverflow a while ago, but no one seemed to be able to help me there and since it is a problem with the XC8 compiler, I thought I would ask here as well.
#1

7 Replies Related Threads

    ric
    Super Member
    • Total Posts : 28378
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Compiling Error with interrupt service routines for ATtiny using xc8 2020/08/03 15:46:42 (permalink)
    +1 (1)
    n.b. MPLAB 5.35 is not the latest release, 5.40 came out some time ago, but I doubt that's your problem.
    The IDE also isn't a very good test of "correct" syntax.
    I don't have any experience at using XC8 on Atmel parts, but an educated guess would be that "RTC_PIT_vect_num" is not defined for some reason.
    Maybe a mispelling or an error in the header file.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    XPModder
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2020/07/10 02:28:39
    • Location: 0
    • Status: offline
    Re: Compiling Error with interrupt service routines for ATtiny using xc8 2020/08/04 09:40:22 (permalink)
    0
    Thank You for the reply, but unfortunately that is not the case. I checked the spelling and even copied it directly from the header file. And the header file is also included correctly, as other definitions are working fine. Only interrupt service routines seem to be a problem.
    #3
    andersm
    Super Member
    • Total Posts : 2840
    • Reward points : 0
    • Joined: 2012/10/07 14:57:44
    • Location: 0
    • Status: offline
    Re: Compiling Error with interrupt service routines for ATtiny using xc8 2020/08/04 09:56:44 (permalink)
    0 (2)
    The __interrupt() specifier requires the CCI language extensions, are they enabled in the project options? Without CCI, you should still be able to use the old AVR Libc syntax:
    #include <avr/interrupt.h>
     
    ISR(RTC_PIT_vect_num)
    {
        ...
    }

    #4
    ric
    Super Member
    • Total Posts : 28378
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Compiling Error with interrupt service routines for ATtiny using xc8 2020/08/04 13:22:41 (permalink)
    0
    XPModder
    Thank You for the reply, but unfortunately that is not the case. I checked the spelling and even copied it directly from the header file. And the header file is also included correctly, as other definitions are working fine. Only interrupt service routines seem to be a problem.

    Just as a matter of interest, which exact header file is this? I couldn't find one for that device in my installs of XC8.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #5
    XPModder
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2020/07/10 02:28:39
    • Location: 0
    • Status: offline
    Re: Compiling Error with interrupt service routines for ATtiny using xc8 2020/08/04 13:32:04 (permalink)
    0
    Thank You very much andersm!
    The CCI language extension not being enabled was indeed the problem!
    So that is fixed now!
    #6
    XPModder
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2020/07/10 02:28:39
    • Location: 0
    • Status: offline
    Re: Compiling Error with interrupt service routines for ATtiny using xc8 2020/08/04 13:36:50 (permalink)
    +1 (1)
    @ric
    The header file is called "iotn202.h" and I needed to downgrade back to version 2.10 of XC8, because it is for some reason missing in the later versions of XC8...
    I dont know why it is no longer included... The Attiny202 is still in production as far as I know, so the header should really be included in the current compiler versions.
     
    #7
    ric
    Super Member
    • Total Posts : 28378
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Compiling Error with interrupt service routines for ATtiny using xc8 2020/08/04 13:48:46 (permalink)
    0
    Thanks.
    I found the file IS present in XC8 version 2.20, in the folder at
    C:\Program Files\Microchip\xc8\v2.20\dfp\xc8\avr\include\avr
    I was looking in
    C:\Program Files\Microchip\xc8\v2.20\avr\avr\include\avr
     
    I'm still coming to grips with these new "device packs" Microchip are using. It means you end up with multiple copies of the same files.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #8
    Jump to:
    © 2020 APG vNext Commercial Version 4.5