MPLABX 1.1 & XC8 Compiler

Author
Tomw
Starting Member
  • Total Posts : 59
  • Reward points : 0
  • Joined: 2010/11/12 16:48:50
  • Location: 0
  • Status: offline
2012/03/31 11:31:50 (permalink)
0

MPLABX 1.1 & XC8 Compiler

 I installed the newest version of MPLABX and the XC8 compiler. Created a new project and copied in one of the source files I use in MPLAB 8.84. MPLABX and the XC8 compiler can't seem to change Port B Pin 6. I thought at first it was the chip, so I mounted a new chip and tried a new board as well. I shutdown MPLABX and started MPLAB 8.84, compiled the same program and it ran flawlessly. Then I noticed MPLAB 8.84 was using the XC8 compiler instead of the HiTech 9.83 version. When I tried to switch it back the HiTech compiler was no longer in the list of tool chains avaliable. What happened to my functioning MPLAB 8.84 installation? XC8 also gave me warnings like "unable to resolve identifier" on a line like "int digit1;.
#1

16 Replies Related Threads

    Tomw
    Starting Member
    • Total Posts : 59
    • Reward points : 0
    • Joined: 2010/11/12 16:48:50
    • Location: 0
    • Status: offline
    Re:MPLABX 1.1 & XC8 Compiler 2012/03/31 16:02:29 (permalink)
    0
    To clarify the above a bit. The same exact program, a simple 4 digit counter, compiled under MPLABX and XC8 is unable to toggle port B6. Compiled under MPLAB 8.84 it works fine. The same source code, the same compiler, the same chip, the same PICKIT3. The warnings I was getting were the result of a stray character in the code and are unrelated.
    #2
    Mark201
    Super Member
    • Total Posts : 278
    • Reward points : 0
    • Joined: 2008/04/03 06:46:34
    • Location: Lynnfield, MA.
    • Status: offline
    Re:MPLABX 1.1 & XC8 Compiler 2012/03/31 20:53:25 (permalink)
    0
    Lets see the code. 

    Mark
     
    MPLABX 1.10
    C18 V3.41
    C30 V3.31
    MPLAB 8.83
    ICD3
    #3
    Tomw
    Starting Member
    • Total Posts : 59
    • Reward points : 0
    • Joined: 2010/11/12 16:48:50
    • Location: 0
    • Status: offline
    Re:MPLABX 1.1 & XC8 Compiler 2012/04/01 09:13:41 (permalink)
    0
     Here's the code

    Attachment(s)

    Attachments are not available: Download requirements not met
    #4
    drazen
    Super Member
    • Total Posts : 2847
    • Reward points : 0
    • Joined: 2003/11/07 12:43:09
    • Location: Croatia
    • Status: offline
    Re:MPLABX 1.1 & XC8 Compiler 2012/04/01 10:07:16 (permalink)
    +2 (1)
    O my God what a code!
    #5
    dan1138
    Super Member
    • Total Posts : 2496
    • Reward points : 0
    • Status: offline
    Re:MPLABX 1.1 & XC8 Compiler 2012/04/01 13:06:51 (permalink)
    0
    Tomw

     Here's the code

    There are more that 500 PIC microcontrollers that might be the traget device for the code you posted.
     
    Perhaps you would favor us with a clue to the one you are using?
    #6
    Tomw
    Starting Member
    • Total Posts : 59
    • Reward points : 0
    • Joined: 2010/11/12 16:48:50
    • Location: 0
    • Status: offline
    Re:MPLABX 1.1 & XC8 Compiler 2012/04/01 13:07:02 (permalink)
    0
    Thank you so much for your comment. I didn't ask for a critique of my coding style, I asked why two versions of MPLAB worked differently with regard to one port pin. If you can't explain that then please move along and allow someone who can to answer.
    #7
    Tomw
    Starting Member
    • Total Posts : 59
    • Reward points : 0
    • Joined: 2010/11/12 16:48:50
    • Location: 0
    • Status: offline
    Re:MPLABX 1.1 & XC8 Compiler 2012/04/01 16:33:20 (permalink)
    0
     Since there seems to be a few people on here that don't like my style of coding, I simplified the problem a bit. #include "xc.h" __CONFIG (FOSC_INTRC_NOCLKOUT & WDTE_OFF & MCLRE_ON & CPD_OFF & LVP_OFF & IESO_OFF & FCMEN_OFF); __CONFIG (BOR4V_BOR21V & WRT_OFF); int main(void) { unsigned int a,b; a = 0x00; b = 0x01; TRISB = 0; while(a < b){ PORTB = 0x00; _delay(200); PORTB = 0xff; _delay(200); } } Using XC8 with MPLAB 8.4 all 8 pins of port b toggle at around 2.38 khz Using XC8 with MPLABX pins 0-5 of port b toggle at around 2.38 khz Pins 6&7 do not. Same chip, same board, same PICKIT3, same compiler.
    #8
    Tomw
    Starting Member
    • Total Posts : 59
    • Reward points : 0
    • Joined: 2010/11/12 16:48:50
    • Location: 0
    • Status: offline
    Re:MPLABX 1.1 & XC8 Compiler 2012/04/01 16:34:50 (permalink)
    0
    Oops, it's a 16F886
    #9
    Mark201
    Super Member
    • Total Posts : 278
    • Reward points : 0
    • Joined: 2008/04/03 06:46:34
    • Location: Lynnfield, MA.
    • Status: offline
    Re:MPLABX 1.1 & XC8 Compiler 2012/04/01 17:48:11 (permalink)
    0
    Try this instead

    int main(void)
    {
        unsigned int a,b;
        a = 0x00;
        b = 0x01;
        TRISB = 0;
        while(a < b)
        { 
            LATB = 0x00;
            _delay(200); 
            LATB = 0xff;
            _delay(200);
        }
    }
    TRIS = 0;
    LAT is writing out to pin.

    TRIS = 1;
    PORT is reading in from pin


    Mark
     
    MPLABX 1.10
    C18 V3.41
    C30 V3.31
    MPLAB 8.83
    ICD3
    #10
    Guest
    Super Member
    • Total Posts : 80499
    • Reward points : 0
    • Joined: 2003/01/01 00:00:00
    • Location: 0
    • Status: online
    Re:MPLABX 1.1 & XC8 Compiler 2012/04/01 18:25:21 (permalink)
    0
    port b toggle at around 2.38 khz Pins 6&7 do not

    Pins 6 & 7 are the in circuit debug pins so the DEBUG bit in CONFIG1 is set because you or MPLAB X screwed up.
    #11
    Tomw
    Starting Member
    • Total Posts : 59
    • Reward points : 0
    • Joined: 2010/11/12 16:48:50
    • Location: 0
    • Status: offline
    Re:MPLABX 1.1 & XC8 Compiler 2012/04/01 19:16:33 (permalink)
    0
    Ahaaaaaaaaaaaa! Thank you!
    #12
    DarioG
    Scheisse Menschen
    • Total Posts : 52256
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: hi there
    • Status: online
    Re:MPLABX 1.1 & XC8 Compiler 2012/04/02 00:48:34 (permalink)
    0
    Hmm, that "old" PIC16 has no LATx registers ... Smile

    Dario Greggio
    --
    Wouldn't it be wonderful, if you lost one son for every promise you don't keep?
    #13
    Mark201
    Super Member
    • Total Posts : 278
    • Reward points : 0
    • Joined: 2008/04/03 06:46:34
    • Location: Lynnfield, MA.
    • Status: offline
    Re:MPLABX 1.1 & XC8 Compiler 2012/04/02 04:53:15 (permalink)
    0
    Good catch.  Does that mean using Bank select?  
    [8D]

    Something like this?

    BANKSEL PORTB
     PORTB= 0x00
    _delay(200)
    BANKSEL PORTB
    PORTB =0xFF
    _delay(200);

    Mark
     
    MPLABX 1.10
    C18 V3.41
    C30 V3.31
    MPLAB 8.83
    ICD3
    #14
    drazen
    Super Member
    • Total Posts : 2847
    • Reward points : 0
    • Joined: 2003/11/07 12:43:09
    • Location: Croatia
    • Status: offline
    Re:MPLABX 1.1 & XC8 Compiler 2012/04/02 05:28:59 (permalink)
    0
    If you are using C than banksel is not necessary cause it is added by compiler automaticaly. It is only necessary for assembly. Of course, SFR area does not need banksel (true for C18).
    If you open disassembly listing you will see millions of banksel. Only optimizations will remove some of them.

    I do not know for XC8 but with C18 you can define variables as near and banksel is not needed. Problem is that you only have 128 bytes.
    #15
    Tomw
    Starting Member
    • Total Posts : 59
    • Reward points : 0
    • Joined: 2010/11/12 16:48:50
    • Location: 0
    • Status: offline
    Re:MPLABX 1.1 & XC8 Compiler 2012/04/02 07:16:05 (permalink)
    0
    Strange though that the two IDEs would give different results from the same compiler.
    #16
    drazen
    Super Member
    • Total Posts : 2847
    • Reward points : 0
    • Joined: 2003/11/07 12:43:09
    • Location: Croatia
    • Status: offline
    Re:MPLABX 1.1 & XC8 Compiler 2012/04/02 07:53:24 (permalink)
    0
    I was just reading XC8 manual and you can choose between HiTech and C18 mode - thanks God!

    Code produced must be identical but each IDE uses it's own set of compiler params. X is doing this wrong and differently than MPLAB 8 (did we expect something else).
    #17
    Jump to:
    © 2017 APG vNext Commercial Version 4.5