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 |
---|---|---|
| | |
| |
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
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
Click Finish
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
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.
10
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
Click Select
Project window after source file has been added to a project
11
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.