Measuring Power Consumption with PAC1934 Step 2: Create and Set Up MPLAB X IDE Project

Last modified by Microchip on 2024/06/24 06:31

Create MPLAB X IDE Project

Create an MPLAB X IDE project for the PIC24FJ256GA705 using the MPLAB XC16 compiler.

Information

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.


Download and Extract Example Code

Download the example file pac1934-app-pic24fjxxxga7.X.zip and extract files into <your unzip folder>.

Unzip


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:

  • DisplayDriver
  • MeterDrivers
  • UserInterface
  • App.c
  • App.h

Copy Folders


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.
Information

Note: This step will create logical folders in your project and populate them with the required files.

Information

Note:

  • 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.

Add header files

Select Source File Folder

Here is how your Add Files window should look:

Add source file for the headers


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.

Add app source file

Select app header file

Information

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.


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.

Add source files

Select Source File Folder

Source Files Folders for Sources


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.

add app header filee

Select app header file


Install MPLAB Code Configurator (MCC)

If needed, install MCC. We will use it to graphically create peripheral drivers for this tutorial.


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.

Download the PAC193x MCC Library from the PAC1934 product page or the MCC page.

Check for the latest version, in this project we use version v2.2.

check for version

check for version URL