Which Device Header Files are Used to Build Your Project?

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

MCU header files are included in the Device Family Packs (DFPs) which are installed in various locations on your PC:

  • DFP artifacts embedded within an MPLAB® Harmony 3 project
  • DFPs installed/maintained by the Integrated Development Environment (IDE)
  • DFP artifacts installed with the compiler

Since there can be multiple copies and versions of the DFP installed on your computer, how do you know which device header file will be used in the build?

The default method that the compiler uses to select the device header file is a prioritized search of the project. The compiler will use the first header file found as it goes through this search order.

However, there are ways to ensure that it uses the header file that you want. The first way is to include it explicitly in your project (like in the MPLAB Harmony 3 project), since that is the first place the compiler will look. 

Or, if you wish to use the IDE-managed DFP, but have multiple versions downloaded, you can choose the version you wish to use in the Project Properties window as shown in the "Selecting the DFP Version Used by the IDE" section.

Finally, if you want to force the compiler to use its own version of the header, you can choose to override the others with a switch in the compiler global options tab of the Project Properties window as shown in the "Override the IDE Settings to Choose Compiler's Header File" section.

Back to Top

Compiler Default Selection Method: Prioritized Search

Priority 1 - Search Project Files

The first location searched is the project itself. MPLAB Harmony 3 projects are self-contained. DFPs in the MPLAB Integrated Development Environment (IDE) and MPLAB XC32 are ignored.

Project packs

Back to Top

Priority 2 - Search IDE-Managed DFPs

If no local header files are found in the project, the DFPs in the IDE are used. The version can be selected in the Project Properties window.

Project packs

Back to Top

Priority 3 - Search Compiler DFPs

If no other DFP is present, the XC compiler can use its own header files:

Compiler toolchain

Back to Top

Selecting the DFP Version Used by the IDE

1. Select DFP to Change

In the Dashboard window, click on the DFP that you wish to change. This will open the Project Properties window.

SAME54_DFP

Back to Top

2. Select the DFP That You Want

In the Project Properties window, select the DFP version that you wish to use and click the OK button to save your selection.

DFP

Back to Top

Override the IDE Settings to Choose Compiler's Header File

Because it is that last default location checked by the compiler when searching for the header file, DFPs in the XC compilers are normally ignored unless you override the IDE setting:

Do not override selected

Back to Top