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
Hardware Tools (Optional)
|Tool|| About|| Purchase|
| Windows|| Linux|| Mac OSX|
Integrated Development Environment
The contents of the following zip file need to be placed in this directory:
| Windows|| Linux|| Mac OSX|
Project and Source Files
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
Start Project CreationClick the New Project icon to start the project creation process
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
Congratulations! You have just created an MPLAB® X project
We will now add source code files to the project.
Move Source Files into the Project Folder
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”
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.
Adding Files to the Project
Right click on the Source Files folder in the project window
Select Add Existing Item
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
Project window after source file has been added to a project
Open the Editor
Double click on the Lab01.c file to open editor
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.