• AVR Freaks

Hot!Import MPLAB8.x project into MPLABX - How?

Author
silver_mica
Starting Member
  • Total Posts : 75
  • Reward points : 0
  • Joined: 2010/09/05 20:19:54
  • Location: San Jose, CA
  • Status: offline
2019/11/13 20:03:30 (permalink)
0

Import MPLAB8.x project into MPLABX - How?

I'm trying to run an example program (lessons) written years ago for the 44 Pin Demo Board PIC18F45k20. It's pretty generic - and probably came on a disk (or was downloadable) with the kit.

I don't have the original MPLAB 8.x files or the original lesson code - but I did find MPLAB 8.92 and installed that on a Win10 machine. Then I needed the lesson code - which I believe I got from here:


http://ww1.microchip.com/...0Express%20Lessons.zip


So, initially, a direct import into MPLABX didn't work. (missing h files - then when I found h files it wanted - there were further definitions that the compiler didn't know about).

So.... I landed here:

https://microchipdevelope...b-8-project-to-mplab-x


Sounds like I may need to first open the project up in in MPLAB 8.x and then save (presumably compile then save)

Here's an excerpt from the above link:

From time to time, the project file format of MPLAB 8.x and earlier has changed. To ensure that you are using the latest project file format before attempting the conversion, first save your project with MPLAB 8.14.03A or later.

The problem now is the missing compiler. I don't believe there is any compiler that automatically comes with the MPLAB 8.x IDE. True?

It appears (from glancing at http://ww1.microchip.com/...n/DeviceDoc/41370C.pdf documentation) that the compiler I need is the C Compiler for the PIC18.

The following link has a bunch of archived tools and compilers - including upgrade version of the C Compiler for the PIC18 (possibly for 32-bit machines only?)

https://www.microchip.com...spic-downloads-archive


I have download the latest version of the upgrade C Compilers for the PIC18 from the above link - but, not surprisingly, when I tried to install - it told me there were no previous versions.

So, I still believe I have zero compilers.

I am under the impression that I must first open up an old MPLAB project in MPLAB8.x, compile, then save before importing into MPLABX.

Is it the case that these older programs will simply never work with MPLABX? Not theoretically, but in a practical sense - for example if it's next to impossible to obtain a compiler.

Is it money they want? If I buy the correct tools will I be able to open and compile these old projects?

Should I ditch the old hardware and just buy something new that works with MPLABX?

My main goal here was to get a development platform running in MPLABX - but for many years now I avoided MPLABX because nothing ever worked for me. Why switch when everything was fine in MPLAB8.x - right? That was then - all my old computers are gone and I'd like to rebuild. I have a lot of old projects - but I'm not optimistic there will be an easy way to just open and compile my old projects again with out a big fuss - if it's even possible in the first place. =(

Well, this was just for fun anyway.
 
 
#1

6 Replies Related Threads

    ric
    Super Member
    • Total Posts : 24638
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Import MPLAB8.x project into MPLABX - How? 2019/11/13 20:28:30 (permalink)
    +1 (1)
    Yes, those old projects are designed for C18, which is no longer available.
    XC8 is the free replacement for C18. It is very similar, but not 100% compatible.
     

    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
    silver_mica
    Starting Member
    • Total Posts : 75
    • Reward points : 0
    • Joined: 2010/09/05 20:19:54
    • Location: San Jose, CA
    • Status: offline
    Re: Import MPLAB8.x project into MPLABX - How? 2019/11/13 21:37:05 (permalink)
    0
    I have my doubts that XC8 will work with MPLAB 8.92.
    post edited by silver_mica - 2019/11/13 21:41:17
    #3
    ric
    Super Member
    • Total Posts : 24638
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Import MPLAB8.x project into MPLABX - How? 2019/11/13 22:08:28 (permalink)
    +1 (1)
    XC8 v1.xx will work in MPLAB8.
    Up to v1.33 will "just work".
    v1.34 on need some tweaking to make them work. See: How to install XC8 version 1.34 and later into MPLAB8.
     
     

    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!
    #4
    Mysil
    Super Member
    • Total Posts : 3488
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: Import MPLAB8.x project into MPLABX - How? 2019/11/14 09:10:36 (permalink)
    0
    Hi,
    There are some changes needed in code written for C18 compiler,
    to work with XC8 compiler.
    I have gone thru one of the mentioned examples with MPLAB 8.92  and XC8 v1.45 
    Be aware that I have both  XC8 v 1.45 and XC8 v1.33  still installed, see message #4 from ric
    For example '03 Rotate LED.c'  it have become like this:  
    //******************************************************************************
    //Software License Agreement                                         
    //                                                                    
    //The software supplied herewith by Microchip Technology             
    //Incorporated (the "Company") is intended and supplied to you, the  
    //Company’s customer, for use solely and exclusively on Microchip    
    //products. The software is owned by the Company and/or its supplier,
    //and is protected under applicable copyright laws. All rights are   
    //reserved. Any use in violation of the foregoing restrictions may   
    //subject the user to criminal sanctions under applicable laws, as   
    //well as to civil liability for the breach of the terms and         
    //conditions of this license.                                        
    //                                                                    
    //THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,  
    //WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED  
    //TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A       
    //PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,  
    //IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR         
    //CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.       
    // *******************************************************************
    // PICkit 2 PIC18F4520 Lesson 3 - Rotate LED
    //
    // This lesson lights LEDs 0-7 in sequence, one at a time.
    //
    // *******************************************************************
    // *    See included documentation for Lesson instructions           *
    // *******************************************************************

    /** C O N F I G U R A T I O N   B I T S ******************************/

    #pragma config FOSC = INTIO7, FCMEN = ON, IESO = OFF   // FCMEN = OFF                  // CONFIG1H
    //#pragma config FOSC = INTIO67, FCMEN = ON, IESO = OFF   // FCMEN = OFF                  // CONFIG1H
    #pragma config PWRT = OFF, BOREN = SBORDIS, BORV = 27                       // CONFIG2L
    //#ifdef  __DEBUG
      #pragma config WDTEN = OFF, WDTPS = 32768                                 // CONFIG2H
      #pragma config MCLRE = ON
    //#else
    //  #pragma config WDTEN = ON,  WDTPS = 256    // 128                                 // CONFIG2H
    //  #pragma config MCLRE = OFF
    //#endif
    #pragma config LPT1OSC = OFF, PBADEN = ON, CCP2MX = PORTC                   // CONFIG3H
    #pragma config STVREN = ON, LVP = OFF, XINST = OFF                          // CONFIG4L
    #pragma config CP0 = OFF, CP1 = OFF, CP2 = OFF, CP3 = OFF                   // CONFIG5L
    #pragma config CPB = OFF, CPD = OFF                                         // CONFIG5H
    #pragma config WRT0 = OFF, WRT1 = OFF, WRT2 = OFF, WRT3 = OFF               // CONFIG6L
    #pragma config WRTB = OFF, WRTC = OFF, WRTD = OFF                           // CONFIG6H
    #pragma config EBTR0 = OFF, EBTR1 = OFF, EBTR2 = OFF, EBTR3 = OFF           // CONFIG7L
    #pragma config EBTRB = OFF                                                  // CONFIG7H


    /** I N C L U D E S **************************************************/
    #include <xc.h>
    //#include "p18f46k20.h"
    //#include "delays.h"

    /** V A R I A B L E S *************************************************/
    //#pragma udata // declare statically allocated uninitialized variables
    unsigned char LED_Number;  // 8-bit variable

    /** D E C L A R A T I O N S *******************************************/
    // declare constant data in program memory starting at address 0x180
    #ifdef __XC8
    #define  _XTAL_FREQ 1000000
    const unsigned char LED_LookupTable[8] = {0x01, 0x02, 0x04, 0x08,
                                                     0x10, 0x20, 0x40, 0x80};
    #else
    #pragma romdata Lesson3_Table = 0x180
    const rom unsigned char LED_LookupTable[8] = {0x01, 0x02, 0x04, 0x08,
                                                     0x10, 0x20, 0x40, 0x80};

    #pragma code    // declare executable instructions
    #endif
    void main (void)
    {
        LED_Number = 0;            // initialize

        TRISD = 0b00000000;         // PORTD bits 7:0 are all outputs (0)

        while (1)
        {
            // use lookup table to output one LED on based on LED_Number value
            LATD = LED_LookupTable[LED_Number];    

            LED_Number++;      // rotate display by 1

            if (LED_Number == 8)
            {    LED_Number = 0;    // go back to LED 0.
                CLRWDT();
        //        ClrWdt();
            }
            __delay_ms(125);       /* 125 millisecond for 8 LEDs in 1 second. */
        //    __delay_ms(200);       /* Delay macro provided by XC8 compiler. */
            CLRWDT();
        //    Delay1KTCYx(50);        // Delay 50 x 1000 = 50,000 cycles; 200ms @ 1MHz
        //    ClearWdt();
        }    
    }
     

    Generally, code that was there remain as comment lines.
    #pragma udata , #pragma romdata  and  #pragma code   are removed
    Storage of an array in Flash memory is done by use of const keyword:
    const unsigned char LED_LookupTable[8] = {0x01, 0x02, 0x04, 0x08,
                                                     0x10, 0x20, 0x40, 0x80};
     
    #define  _XTAL_FREQ 1000000 //  Estimate of system clock frequency expected, and
     
            __delay_ms(125);        // are used for time delays.

    This run both in debug and production mode on PIC18F45K20  on the PICkit 44-pin Demo Board.
    I will try to attach the package file.
     
    Regards,
        Mysil
     
     
     
     
     
     
    post edited by Mysil - 2019/11/14 09:16:25

    Attachment(s)

    Attachments are not available: Download requirements not met
    #5
    Mysil
    Super Member
    • Total Posts : 3488
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: offline
    Re: Import MPLAB8.x project into MPLABX - How? 2019/11/14 10:05:35 (permalink)
    0
     
    MPLAB X    is known to be picky about space characters, and other special characters in filenames 
    and directory  names,
    so  I have replaced space characters with _underscore.
     
    This have successfully converted to MPLAB X v5.25  ,
    selecting XC8 v1.45 as the compiler to use.
    This run in debug and production.
     
    However after changing compiler to XC8 v2.10  in Project Properties ,
    and then build,
    BUILD SUCCESSFUL (total time: 253ms)
    then it complain about not beeing able to load the image. 
    Until project was closed, MPLAB X  restarted, and project opened again !?
     
    Then it have been possible to make and run the project both in debugger and alone.
     
    For projects with only 1 source file, it may seem easier to fix the source code, 
    and then just make a new standalone project in the new project wizard.
     
        Mysil
     

    Attachment(s)

    Attachments are not available: Download requirements not met
    #6
    silver_mica
    Starting Member
    • Total Posts : 75
    • Reward points : 0
    • Joined: 2010/09/05 20:19:54
    • Location: San Jose, CA
    • Status: offline
    Re: Import MPLAB8.x project into MPLABX - How? 2019/11/14 10:51:24 (permalink)
    0
    Hey thanks for reading and providing help.   Still got a question though.  
     
    Do I FIRST need to open the workspace 03_Rotate_LED up in MPLAB8.x, compile, and save BEFORE importing into MPLABX?
    #7
    Jump to:
    © 2019 APG vNext Commercial Version 4.5