You are on page 1of 24

In this tutorial (by taking Cytron Technologies DIY project as an example), you will learn how to: >>

Install the MPLAB X IDE and MPLAB XC8 Compiler >> Add the source file to MPLAB X project >> Convert MPLAB v8 project to MPLAB X project >> Build the codes and load to the targeting device

2.0 Getting Started


We will be using the sample code of DIY project PR5 for this example. You can download it here.

3.0 How to install the MPLAB X IDE and XC8 compiler


3.1 MPLAB X IDE
Steps:

3.2 MPLAB XC8 Compiler


Steps:

4.0 Creating Projects


Standalone Project:
Video on Creating Standalone New Project MPLAB X IDE

By taking DIY Project 5 _ Line Following Robot as an example to build the code, Steps: 1. Start the new project wizard by:

Click the New Project icon on the main toolbar.or Click the main menu and select File New Projector On the keyboard, press: Ctrl + Shift + Nor Right click on the project window(white space), a pop-up menuwill appear and choose New Project

2. Choose the project type:


From the Categories: choose Microchip Embedded On the Projects column: choose Standalone Project

3. Choose the type of device:

Family: All Family (or you can choose the type of family in order to choose the type of device faster)

Device: Type in the type of device use (can choose from the list) PIC16F84a PR 1, 2, 3 PIC16F727 PR 28 PIC16F777 PR 19 PIC16F876A PR 7, 8, 9B, 10A, 10B, 11, 12, 13, 14, 15, 16, 18, 22, 24, 25, 27, 29 PIC16F877A PR 5, 6A, 17, 23, 31

*choose PIC16F877A for this case because the sample code is using PIC16F877A

4.

Select the tool Under Hardware Tools: Choose PICkit 2 (using UIC00B)

5. Select C Compiler or assembler


Choose the corresponding compiler for the source code Depending on the source file using mpasm (v5.45) >> PR 1, 2, & 3 XC8 (v1.00) >> PR 5, 6, 7, 8, 9B, 10A, 10B, 11, 12, 13, 14, 15, 16, 17, 18, 19, 22, 23, 24, 25, 27, 28, 29, 31 *choose XC8 for this case because the sample code is using C language

6. Name the project and choose a directory


Choose the project name as you like Set the location for the project to be created Name the project folder Click finish

Done

5.0 Adding existing file to project


Steps: 1. Project tree

A project tree will appear in the upper left part of the IDE. User is now ready to add the source files to it. Right click on the Source Files Add Existing Item or Add Existing Items from Folders

Choose the corresponding source file from the disk (you have downloaded and extract the file) If you choose to add an existing item: o Select the source file (*.c) *Choose PR5.c for this example. o Choose the store files path from the radio buttons near the bottom right. Choose Relative. o Click the Select button.

If you choose to add existing items from folders: o Click on the Add Folder button o Select a directory that contains files you want to add to the project o Click the Select button in the Select Source File Folder dialog o Repeat for as many folders as you wish to add o Click on the Add button

Done

*Note: The same applies for adding the header file and linker file to the project. 2. Build Code

Build the codes by clicking the

icon on the toolbar

3. Load program

Connect the programmer(with the device connected) to the computer Press or If you are using the PICkit 2 Programmer software, icon to load the program to the device

Download, Install and Open the PICkit 2 Programmer software Go to Tools Check for Communication File Import Hex Project folder dist default production choose the hex file click Open

Click Write

4. Done 6.0 Converting an MPLAB v8 project to MPLAB X Video on converting MPLAB 8 Projects to MPLAB X ID Steps: 1.

Start the new project wizard by: Click the New Project icon on the main toolbar.or Click the main menu and select File New Projector On the keyboard, press: Ctrl + Shift + Nor Right click on the project window(white space), a pop-up menu will appear and choose New Project

2.

3.

4.

5.

6.

7.

8.

9.

10. If the project that you created cannot detect the source files, header files or linker files, you can manually add them to the project that you created by referring to section 5.0 Adding existing file to project

You might also like