Step 5: Tips and Best Practices

Last modified by Microchip on 2026/06/26 07:36

Tips and Tricks That Can Be Used in MPLAB® X IDE

There are three methods to open the project properties window:

  • Right-click on the specific project to access and view its properties.

project drop down menu

  •   Double-click on the highlighted region (Dashboard) shown in the accompanying image.

Dashboard pane

  •  Select Customize as shown in the accompanying image.

select Customize from toolbar drop down


A broken breakpoint can result from optimization settings. For smoother debugging, set the optimization level to 0. To adjust this setting, navigate to Project Properties > xc32-gcc > Option Categories > Optimization > optimization-level, and set the optimization-level to 0

Project Properties window

Project Properties window


To install any additional plugins, go to Tools > Plugins and choose the required plugin that needs to be installed.

Tools drop down


To open the existing project from a local PC, follow these steps:

Navigate to File > Open Project to access the existing project or use Ctrl + Shift + O.

File drop down menu

Go to the location where the project has been downloaded/created (D:\lab1_ide_setup\firmware\lab1_ide_setupgroup) and then click Open Project.

Open Project window

Now, right-click on the project and select Open Required Projects > Open All Projects.

Projects tab

Once the project is opened, the projects (non-secure, secure, group) will be displayed.

Projects tab

Right-click on lab1_ide_setup, the non-secure project, and click Set on Main Project.

project drop down menu


Alternatively, an existing project can also be opened by simply dragging and dropping the file from the local PC to the IDE.

Drag the group project from file explorer (here lab1_ide_setupgroup).

project file in file explorer

Drag the desired file (highlighted in blue) and place it onto the toolbar area of MPLAB® X IDE (highlighted in red).

toolbar area of MPLAB X IDE

Now, right-click on the project and go to Open Required Projects > Open All Projects.

project right click menu

Now all the projects will be opened as shown in the accompanying image.

Projects pane

Information

Note: Ensure the file path is as short as possible; the build will fail if the file path length exceeds 250 characters.


To generate a HEX file (outside the firmware folder), do the following:

Go to Project Properties > Building.

Project Properties window

Enable Excecute this line after build and paste the following command in the blank as shown:

rm -rf ${ProjectDir}/../../hex && mkdir ${ProjectDir}/../../hex && cp ${ProjectDir}/${ImageDir}/*.unified.hex ${ProjectDir}/../../hex
  • rm -rf ${ProjectDir}/../../hex  forcefully removes (deletes) the hex directory located two levels above the ${ProjectDir} directory, along with all its contents.
    • rm is the remove command.
    • -r means recursive (delete directories and their contents).
    • f means force (ignore nonexistent files and never prompt).
  • If the previous command succeeds, && mkdir ${ProjectDir}/../../hex creates a new, empty directory called hex at the same location (two levels above ${ProjectDir}).
  • If the previous command succeeds, && cp ${ProjectDir}/${ImageDir}/*.unified.hex ${ProjectDir}/../../hex copies all files ending with .unified.hex from the ${ImageDir} directory (inside ${ProjectDir}) into the newly created hex directory. 

Project Properties window

Now, click Apply and Ok. 

Upon building the project after adding the above hex command, a HEX file will be generated at the following location: lab1_ide_setup > hex.

hex folder in file explorer

hex file in file explorer

This HEX file is created to provide a standardized, machine-readable representation of the program, which can be loaded onto a microcontroller for execution. It is worth noting that performing a Clean and Build will still generate a unified HEX file in the dist\default\production directory, even without configuring a post-build command. However, we recommend adding the post-build command as it copies the unified HEX file to a more accessible location, eliminating the need to navigate through the project directory structure each time.

HEX file in a more accessible location

Information

Note: Once the post -build command is added, click only Clean and Build Main Project.

Clean and Build menu

Selecting Clean and Build for Debugging Main Project or using the build icon alone will cause the build to fail, as the post-build command is configured for building purposes only and does not support debugging.

Clean and Build icon

Clean and Build menu

Before starting a debug session, ensure that the post-build command is removed, as the debug build will fail if the post-build command is present

Back to Top