Step 2.1: Create MPLAB X IDE Project
Create an MPLAB X IDE project for the PIC24FJ256GA705 using the MPLAB XC16 compiler.
Note: We’ll refer to your chosen project location as <your MPLAB X IDE project folder>.
You can refer to "Create a Standalone Project" if you would like detailed steps on how to create an MPLAB X IDE project.
Step 2.2: Download and Extract Example Code
Download the example file pac1934-app-pic24fjxxxga7.X.zip and extract files into <your unzip folder>.
Step 2.3: Copy Required Files, Folders from Demo Project
Copy all folders and files from pac1934-app-pic24fjxxxga7.X demo project into <your MPLAB X IDE project folder>. This step is necessary to create a self-contained project with no dependencies on the demonstration project similar to creating your own application.
Here are the files and folders you will need to complete this training:
Step 2.4: Add Content to MPLAB X IDE Project
Add PAC1934 library header files from the demonstration project to your project.
- In MPLAB X IDE, right-click Header Files folder of your project, select Add Existing Items from Folders, click Add Folder…, change Files of type to Header Files, navigate to <your MPLAB X IDE project folder>, select each of the three folders and press the Select button.
Note: This step will create logical folders in your project and populate them with the required files.
- Only one folder can be selected at a time, so this step needs to be repeated for the remaining two folders.
- MPLAB X IDE v5.45 has a restriction that requires the file type to be selected before the folder.
Here is how your Add Files window should look:
Step 2.5: Add App.h File
Next, right-click the Header Files folder again, select Add Existing Item…, select App.h from <your MPLAB X IDE project folder>. Ensure the Copy box is unchecked.
Note: If you are interested in the differences between Auto, Relative, and Absolute store path options, you can read about them in Microchip’s Developer Help on "Add Existing File(s) To Project". Any selection will successfully build.
Step 2.6: Add Source Files
To add the source files from the PAC1934 library, we will repeat the process but change the file type.
- Right-click the Source Files folder in MPLAB X IDE and select Add Existing Items from Folders…, click on Add Folder… and navigate and open <your MPLAB X IDE project folder>, verify Files of type pulldown has C Source Files selected, highlight the first of the three folders and press the Select button. Repeat the process to add the remaining two folders and press the Add button to add the folders and files.
Step 2.7: Add App.c File
Next, right-click the Source Files folder again, select Add Existing Item…, select App.c from <your MPLAB X IDE project folder>. Ensure the Copy box is unchecked. All of the required files to build the project have now been added.
Step 2.8: Install MPLAB Code Configurator (MCC)
If needed, install MCC. We will use it to graphically create peripheral drivers for this tutorial.
- You can refer to "Install MPLAB® Code Configurator (MCC)" if you would like detailed steps on how to do this.
Step 2.9: Install PAC193x MCC Library
The PAC193x MCC Library is a custom MCC library used to graphically add driver code associated with the PAC1934 metering IC.
Check for the latest version, in this project we use version v2.2.
- You can refer to "How to add a library in MPLAB Code Configurator (MCC)" if you would like detailed steps on how to do this.