Lab 1 - Creating an MPLAB X Project (rev. 3.00)

NOTE: Microchip updates its tools regularly. This page is an older version that we have preserved for the convenience of those who are supporting existing designs based upon older versions of our tools. Please check https://microchip-dev.wikidot.com/tls0101:lab1 for the updated version of this page.

 Objective

Lab Exercise 1 shows how to create, edit, and build projects with MPLAB® X IDE. This lab is a step by step walk through of MPLAB X project development. An MPLAB X project is created and an existing C source file is then added to the project. The lab continues with the editing of the source file and the successful build of a project. The lab includes exercises to demonstrate some useful file and data manipulation features of MPLAB X IDE

 Materials

Hardware Tools (Optional)

Tool About Purchase
Explorer16-50px.png
Explorer 16
Development Board
ICD3-50px.png
MPLAB® ICD 3
In-Circuit Debugger

Software Tools

Tool About Installers
Installation
Instructions
Windows Linux Mac OSX
MPLAB® X
Integrated Development Environment
MPLAB® XC16
C Compiler

Exercise Files

The contents of the following zip file need to be placed in this directory:
C:\MTT\TLS0101

File Download
Installation
Instructions
Windows Linux Mac OSX
Project and Source Files

 Procedure

1

Project Creation

Open MPLAB X IDE

Close any open projects in MPLAB X IDE by right clicking on the project name and selecting Close or by going to File and choosing Close All Projects.

When MPLAB® X starts it opens the last project worked on. To avoid confusion, this lab asks to you close any open project

2

Start Project Creation

Click the New Project Main_New_Project.png icon to start the project creation process

3

New Project Window

Select “Microchip Embedded” then “Standalone Project”.

NewProjectWindow.png

4

Processor Selection

Select “16-bit MCUs (PIC24)” from the ‘Family’ pull down menu, then select “PIC24FJ128GA010” from the ‘Device’ menu.

SelectDevice.png

We are using the PIC24FJ128GA010 as the microcontroller for this lab.

Click Next SmallNext.png

5

Header Selection

No header is needed; select “None”

SelectHeader.png

Debug Headers are usually only required for some of the 8 bit controllers with very low pin counts. If you are using a 16-bit, 32-bit or 8-bit with more than 14 pins a header might not be needed.

Click Next SmallNext.png

6

Hardware Selection

Select “Simulator” under Hardware tools when asked to select a tool.

SelectHardware.png
Click Next SmallNext.png

7

Compiler Selection

Open the XC16 plus box, if not already open, and select an installed version of the XC16 compiler

SelectCompiler.png
Click Next SmallNext.png

8

Project Name and Folder Selection

Click the Browse button and navigate to the folder C:\MTT\TLS0101

On the line marked Project Name type in Lab01.

Notice MPLAB® X filling in the Project Folder line with C:\MTT\TLS0101\Lab01.X

ProjectName.png
Click Finish Finish.png

Congratulations! You have just created an MPLAB® X project

We will now add source code files to the project.

9

Move Source Files into the Project Folder

Lab1SourceFiles.png

Using a file manager program (such as Windows Explorer) copy the C file ‘Lab01’ from the folder “C:\MTT\TLS0101\Lab01 Source files” to the newly created folder “C:\MTT\TLS0101\Lab01.X”

ProjectFolder.png

After this step, the Lab01.X folder should contain the subfolder nbproject and two files (as illustrated above)

It is not necessary to add files to a project folder before adding them to a project. Putting all the files into the project folder can make backing up a project easy.

10

Adding Files to the Project

Right click on the Source Files folder in the project window

Select Add Existing Item

AddFiles.png

Highlight the ‘Lab01’ file in the folder C:\MTT\TLS0101\Lab01.X

Ensure the radio button labeled “Relative” in the lower right border of the dialog box is checked

Click Select

Relative.png

Project window after source file has been added to a project

ProjectWindow.png

11

Open the Editor

Double click on the Lab01.c file to open editor

Lab1Code.png

Scroll down so the main() and delay() functions are visible in the editor window

This a very simple program designed to build confidence in your ability to build a project and run it in MPLAB® X.

Upon exiting reset, the PIC® clears PORTA, then configures PORTA pins 0:7 as outputs. It then enters an infinite loop that outputs an alternating pattern to PORTA resulting in the effect of blinking the eight LEDs connected to PORTA. The delay function between each toggle of the LEDs is necessary since LEDs require several ms to turn on or off, whereas the PIC® can toggle in a few hundred ns.

12

Build the Project

Click the Clean and Build Project icon Main_Rebuild_Project.png to build the project
SuccessfulBuild.png

Congratulations! You have finished Lab 1

© 2025 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.