Author Topic: Unable to build basic PIC16 project in MPLAB X  (Read 970 times)

0 Members and 1 Guest are viewing this topic.

Offline newtekuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 401
  • Country: us
Unable to build basic PIC16 project in MPLAB X
« on: December 30, 2022, 12:26:18 am »
Hello All,


I am trying to build the PIC16 template which I'm planning to use as a skeleton for my PIC16F887 project in MPLAB X (6.05) to no avail. When I hit build I get the following errors.
However, if I comment out the offending code in attached interrupts.c, the project builds but I think that's wrong.

Attached is a screenshot of my config. Am I doing something wrong here considering all source files came from mplab? Maybe I'm just using it wrong.



Code: [Select]
interrupts.c:23:6: error: variable has incomplete type 'void'
void interrupt isr(void)
     ^
interrupts.c:23:15: error: expected ';' after top level declarator
void interrupt isr(void)


Thanks!
 

Offline newtekuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 401
  • Country: us
Re: Unable to build basic PIC16 project in MPLAB X
« Reply #1 on: December 30, 2022, 12:44:19 am »
Solved it by changing the function signature for interrupts in interrupts.c from this:

Code: [Select]
void interrupt isr(void)
to this:

Code: [Select]
void __interrupt() isr(void)
I still don't understand why this doesn't work out of the box.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 4303
  • Country: us
Re: Unable to build basic PIC16 project in MPLAB X
« Reply #2 on: December 30, 2022, 02:14:05 am »
You've probably been hit with "political correctness" in a newer versions of the compile than the template was originally written for.  Using an all-lowercase keyword for an internal function (whether it's a compiler intrinsic or a vendor-provided macro) is "bad form."  (and the double-underscores are one of the ways that you're supposed to signify "this identifier is provided by the compiler infrastructure.")
 
The following users thanked this post: newtekuser

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3523
  • Country: it
Re: Unable to build basic PIC16 project in MPLAB X
« Reply #3 on: December 30, 2022, 06:27:41 am »
Solved it by changing the function signature for interrupts in interrupts.c from this:

Code: [Select]
void interrupt isr(void)
to this:

Code: [Select]
void __interrupt() isr(void)
I still don't understand why this doesn't work out of the box.

because RTFM the XC8 compiler manual, specifically the chapter about interrupts.
Basically, first version is for the old compilers, or for the current compilers in C90 mode.
The second version is for the compiler in C99 mode, which has been the default for a few years now
 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6225
  • Country: es
Re: Unable to build basic PIC16 project in MPLAB X
« Reply #4 on: December 30, 2022, 07:16:06 am »
Do yourself a favour and check XC8 User's guide.
Hint:  Section 5.9.1: "Writing an Interrupt Service Routine"  ;)
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 
The following users thanked this post: newtekuser

Offline newtekuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 401
  • Country: us
Re: Unable to build basic PIC16 project in MPLAB X
« Reply #5 on: December 30, 2022, 04:41:33 pm »
Thanks! A bit of a learning curve coming from MikroC PRO :o
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf