Author Topic: Microchip XC8 Compiler Build Errors  (Read 3754 times)

0 Members and 1 Guest are viewing this topic.

Offline mrhoola

  • Newbie
  • Posts: 2
  • Country: us
Microchip XC8 Compiler Build Errors
« on: October 30, 2018, 02:58:43 am »
User Level: Newbie
Compiler: XC8
IDE: MPLAB X
MCU: PIC16f18324 (Mid-Range Enhanced, 8-bit)

Program description: Blink an LED using Timer 0 and interrupts. The source code is in the attachments ("my code.txt")

I have tried everything to get this simple code to successfully run. 
1. Checked the program for logical/syntax errors
2. Configured the project  with the correct settings, file names, and location
3. Referred to the MPLAB XC8 Compiler manual to see if I set up the interrupt correctly
4. Referred to another post regarding the same issue: https://www.eevblog.com/forum/microcontrollers/microchip-xc8-compiler-problems/
5. Re-installed the compiler

I don't know what to do, I've read everything and I can't this out. Help!!!

Failure Description: Every time I build the code I always get the following errors:

CLEAN SUCCESSFUL (total time: 14ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'C:/Users/Marco/Documents/MPLAB/FirstProject/TimerAndInterrupts.X'
make  -f nbproject/Makefile-default.mk dist/default/production/TimerAndInterrupts.X.production.hex
make[2]: Entering directory 'C:/Users/Marco/Documents/MPLAB/FirstProject/TimerAndInterrupts.X'
"C:\Program Files (x86)\Microchip\xc8\v2.00\bin\xc8-cc.exe"  -mcpu=16F18324 -c  -fno-short-double -fno-short-float -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -Wa,-a -DXPRJ_default=default  -msummary=-psect,-class,+mem,-hex,-file  -ginhx032 -Wl,--data-init -mno-keep-startup -mno-osccal -mno-resetbits -mno-save-resetbits -mno-download -mno-stackcall   -std=c99 -gdwarf-3 -mstack=compiled:auto:auto     -o build/default/production/source.p1 source.c
source.c:124:6: error: variable has incomplete type 'void'
void interrupt MY_ISR(void)
     ^
source.c:124:15: error: expected ';' after top level declarator
void interrupt MY_ISR(void)
              ^
              ;
2 errors generated.
(908) exit status = 1
nbproject/Makefile-default.mk:105: recipe for target 'build/default/production/source.p1' failed
make[2]: *** [build/default/production/source.p1] Error 1
make[2]: Leaving directory 'C:/Users/Marco/Documents/MPLAB/FirstProject/TimerAndInterrupts.X'
make[1]: *** [.build-conf] Error 2
nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed
make: *** [.build-impl] Error 2
make[1]: Leaving directory 'C:/Users/Marco/Documents/MPLAB/FirstProject/TimerAndInterrupts.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed

BUILD FAILED (exit value 2, total time: 1s)
 

Offline oPossum

  • Super Contributor
  • ***
  • Posts: 1102
  • Country: us
  • The other white meat.
Re: Microchip XC8 Compiler Build Errors
« Reply #1 on: October 30, 2018, 04:13:15 am »
XC8 users guide page 34

Code: [Select]
__interrupt() void MY_ISR(void)
{
    TMR0IF = 0;
    LATC5 = 1 ;
    __delay_us(3);
    LATC5 = 0;
}
 
The following users thanked this post: mrhoola

Offline mrhoola

  • Newbie
  • Posts: 2
  • Country: us
Re: Microchip XC8 Compiler Build Errors
« Reply #2 on: October 30, 2018, 04:38:45 am »
Wow, it worked!

My thoughts initially on the PIC16 was that you could have formatted the interrupt as stated in the first two bullets on page 201 MPLAB XC Compiler Manual since there is only one vector for the interrupt- Hence no priority scheme :

5.9.1 Writing an Interrupt Service Routine
The prototype and content of an ISR will vary based on the target device and the project
being compiled. Observe the following guidelines when writing an ISR.
For devices that do not have the ICM module:
• Write each ISR prototype using either the interrupt or
__interrupt()specifiers.
• Use void as the return type and for the parameter specification.
• If your device supports interrupt priorities, with each function use the
low_priority or high_priority arguments to __interrupt(), or use
these as stand-alone specifiers with interrupt.

That is why in my program I did it the way I did. But Thank you so much for your help, I would have never have tried this. ! :)
 

Offline oPossum

  • Super Contributor
  • ***
  • Posts: 1102
  • Country: us
  • The other white meat.
Re: Microchip XC8 Compiler Build Errors
« Reply #3 on: October 30, 2018, 05:09:44 am »
There are unfortunately some omissions in the manual that can cause unexpected problems.

I have observed that is is necessary to set the XC8 C standard to C90 for these to work:
interrupt
short long
itoa()

Possibly others that I have not yet discovered.
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 2689
  • Country: it
Re: Microchip XC8 Compiler Build Errors
« Reply #4 on: October 30, 2018, 09:03:25 am »
why are they omissions? those are non-standard keywords so to adhere to the standard they need to have a double underscore

interrupt -> __interrupt (with the various attributes)
short long, which is used for the non-standard 24 bit type, which was present in stdint.h as int24_t/uint24_t -> __int24,__uint24 (and the compiler should generate a warning when you use short long asking you to use these two types)
itoa is NOT part of the standard C library so i guess it was removed, but an implementation of itoa should be trivial. maybe it will be added again in 2.05 (which is coming out... soon they say. It's been soon for a month :/)
In the past they tried to remove some of the non-standard extensions such as the 24 bit type but it was enabled again in a matter of days and a patch because the custom type is also used internally for multiplication and division :)

keep on reading the fantastic manual! it was written by very competent people and there is virtually nothing that i wasn't able to figure out by just looking at the relevant chapters.
XC8 is also written by very competent people and goes to extreme lenghts to be clever and work around the limitations of the architecture if you write clean and simple code.

two examples
Code: [Select]
unsigned c = 0x55;
c = (c << 1) | (c >> 7);
will be excecuted as a rotate instruction

Code: [Select]
uint16_t read_flash(uint16_t address) {
  uint16_t __rom *progmem_ptr;
  progmem_ptr = (uint16_t __rom *) address;
  return *progmem_ptr;
}
will generate all the code necessary to read flash memory, at any address, on any PIC18. but should work as-is on PIC16 as well. should also work out alignment on its own.

just make sure yo uare reading the correct manual, you have the XC8 manual for C99 mode and the XC8 LEGACY manual for C90 mode
« Last Edit: October 30, 2018, 09:06:35 am by JPortici »
 

Offline cobusve

  • Newbie
  • Posts: 4
  • Country: us
    • Micro Forum
Re: Microchip XC8 Compiler Build Errors
« Reply #5 on: January 29, 2019, 07:14:42 am »
This is not really an omission. With the introduction of XC8 V2.0 a major part of the compiler (the front-end) was entirely replaced. This had some good and some bad consequences. On the positive side it brought the compiler up to the C99 standard, which allows you to use things like named initializers in structures and many other nice C99 goodies, but it also means some changes to a list of things which used to work in the HiTech compiler, but were never standard and portable.

There is a more complete write-up about this here https://www.microforum.cc/topic/5-i-used-to-use-to-locate-variables-but-since-xc8-20-this-is-no-longer-working/

The short version is that there has for some time been a standards compliant way to do things (called the CCI or common compiler interface) with XC8, and the compiler remained backwards compatible with the old HiTech non-standard ways of doing things. With the major version change of the compiler some of these old non-standard things were eventually deprecated.

These chages and deprecations are well documented in both the release notes and the User's Guide.

Also take a look at https://www.microforum.cc/ - a great resource for information on PIC and AVR microcontrollers and embedded programming in general. You can also post questions to the experts there.
 
The following users thanked this post: JPortici


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf