Build Failures after updating MPLabX and XC8

Discussion in 'Programmer's Corner' started by ke5nnt, Nov 22, 2014.

  1. ke5nnt

    Thread Starter Active Member

    Mar 1, 2009
    384
    15
    Good Day All,

    I recently updated to newer versions of MPLabX and XC8 C compiler. C compiler was version 1.12, updated that to 1.33B. I don't remember what version MPLab X was prior to updating, but it is now version 2.26. I backed up my project files and all prior to updating, and then uninstalled MPLAB, XC8, PICC, etc. Then I installed MPLabX and then finally installed the XC8 compiler (that was my update order).

    After doing so, I attempted to write an extremely simple program to demonstrate the software to someone and am now getting failure on build. The program is below, as are the failures. At first, I had noticed that the xc.h file was still pointing to the 1.12 version folder, so I updated those to the new location, which solved those errors. I also changed the compiler setting in the MPLAB options to the new 1.33 version, so that should not be the cause of the issue. Maybe it has just been a while since I wrote a program and my code is the issue, however, I basically copied from an old program that I know used to compile with no issues in the older versions, which is now not compiling. Any ideas? Thanks!

    Please note that the __delay_ms(500) seems to be the cause of the failure. Compiles fine without that, but I've checked the user manual and seem to be meeting all the requirements for using it. I've also checked the pic.h file which includes notes about using __delay_ms(x).
    This code was written for the PIC12F629

    Code (Text):
    1.  
    2. #include <xc.h>
    3.  
    4. #pragma config BOREN = OFF, MCLRE = OFF, PWRTE = ON, WDTE = OFF, FOSC = INTRCIO
    5.  
    6. #define _XTAL_FREQ = 4000000
    7.  
    8. void main()
    9. {
    10.   TRISIO = 0b00001000;
    11.   GPIO = 0;
    12.  
    13.   while(1)
    14.   {
    15.   GP0 = 1;
    16.   __delay_ms(500);
    17.   GP0 = 0;
    18.   }
    19. }
    20.  
    make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
    make[1]: Entering directory 'C:/Users/Ryan/MPLABXProjects/learnc_test.X'
    make -f nbproject/Makefile-default.mk dist/default/production/learnc_test.X.production.hex
    make[2]: Entering directory 'C:/Users/Ryan/MPLABXProjects/learnc_test.X'
    "C:\Program Files (x86)\Microchip\xc8\v1.33\bin\xc8.exe" --pass1 --chip=12F629 -Q -G --double=24 --float=24 --opt=default,+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=0 --asmlist --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -obuild/default/production/learnc_test.p1 learnc_test.c
    learnc_test.c:15: error: (195) expression syntax
    learnc_test.c:15: error: (187) too few function arguments
    learnc_test.c:15: error: (194) ")" expected
    learnc_test.c:15: error: (195) expression syntax
    (908) exit status = 1
    make[2]: *** [build/default/production/learnc_test.p1] Error 1
    make[1]: *** [.build-conf] Error 2
    make: *** [.build-impl] Error 2
    nbproject/Makefile-default.mk:94: recipe for target 'build/default/production/learnc_test.p1' failed
    make[2]: Leaving directory 'C:/Users/Ryan/MPLABXProjects/learnc_test.X'
    nbproject/Makefile-default.mk:78: recipe for target '.build-conf' failed
    make[1]: Leaving directory 'C:/Users/Ryan/MPLABXProjects/learnc_test.X'
    nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed

    BUILD FAILED (exit value 2, total time: 541ms)
     
  2. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    More than likely 500 is too large of a number. Try a smaller number like 5 then build from there to see the limit.
     
  3. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,796
    831
    What happens if you use a parameter less than 500? 255 for example. There often are limits on the delay functions and it may be causing you problems. Try it!

    Spinnaker beat me to it :)
     
  4. ke5nnt

    Thread Starter Active Member

    Mar 1, 2009
    384
    15
    Yes I had thought of that prior to posting the issue, attempting to use a smaller argument. I attempted 5, and 50, and 500, all of which produced the same errors. Should have mentioned that in the original post.
     
  5. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    Are you certain __delay_ms is in one of your header files?

    If it is, does the function in the header have the signature that you expect?

    What are the lines causing the errors? All you list is line numbers and that is of no help.
     
  6. ke5nnt

    Thread Starter Active Member

    Mar 1, 2009
    384
    15
    All errors point to line 15, which is the __delay_ms(500);
    I have successfully used 500 in several other programs prior to my updating the software. Seems that during my uninstall/update cycle, I had uninstalled the Hi-Tech PICC lite package. Looking through the header files, I included <xc.h> which #includes <htc.h> which includes this:
    Code (Text):
    1.  
    2. /* HI-TECH PICC / PICC-Lite compiler */
    3. #if   defined(__PICC__) || defined(__PICCLITE__)
    4. #include <pic.h>
    5. #endif
    6.  
    Not sure if XC8 includes PICC but if it does not, it may be possible that the <pic.h> file is not included, and this is causing the issue?
    <pic.h> is the file which defines the delay routines.
    Code (Text):
    1.  
    2. #ifdef __PICC__
    3. /****************************************************************/
    4. /* Built-in delay routine           */
    5. /****************************************************************/
    6. #pragma intrinsic(_delay)
    7. extern __nonreentrant void _delay(unsigned long);
    8. // NOTE: To use the macros below, YOU must have previously defined _XTAL_FREQ
    9. #define __delay_us(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000000.0)))
    10. #define __delay_ms(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000.0)))
    11. #endif
    12.  
    Searching for PICC brings me to a microchip.com page which specifies "Microchip highly recommends the MPLAB XC8 C Compiler (SW006021-2) for new designs."
     
  7. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    You need to trace back sc.h and htc.h to see if they ineed doing to a header file containing your delay function.
     
  8. JohnInTX

    Moderator

    Jun 26, 2012
    2,341
    1,023
    .. should not have the = sign. _XTAL_FREQ is a macro that will be substituted as raw text - in this case '= 4000000' where the delay functions/macros expect a simple number.

    Welcome back, by the way.
     
  9. ke5nnt

    Thread Starter Active Member

    Mar 1, 2009
    384
    15
    Spinnaker, thank you for all the assistance in trying to help me solve the issue.

    Oh dear God, I can't believe it was that simple. I guess when you take a break from programming like that, it does indeed involve a learning curve. Thanks for noticing my return, great to hear from you!

    Moral of this story, the error is my fault. Goes to show how frustrating programming can be. I've spent 3 hours trying to fix an equals sign.
     
  10. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    988

    Don't feel bad. I did not see it either. And I have made the same dumb mistake. :)
     
    ke5nnt likes this.
  11. JohnInTX

    Moderator

    Jun 26, 2012
    2,341
    1,023
    Don't be too hard on yourself. There isn't any direct connection at the source level and sometimes its not immediately apparent how library routines are constructed and what macros they use. I happen to know how _delay works at the code level. Now you do as well.
    Nice.
     
    ke5nnt likes this.
Loading...