Step 5: Tips and Best Practices
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.

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

- Select Customize as shown in the accompanying image.

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.


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

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.

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

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

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

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

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

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

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

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

To generate a HEX file (outside the firmware folder), do the following:
Go to Project Properties > Building.

Enable Excecute this line after build and paste the following command in the blank as shown:
- 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.

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.


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.



