Lab 7- Debugging and Testing the IoT MPLAB® Harmony Application

Last modified by Microchip on 2025/07/07 15:24

Introduction

This lab training focuses on debugging, testing, and validating the IoT thermostat application on the  SAM9X75 Curiosity Wireless Kit , ensuring reliable operation in a real-world embedded environment. Using the MPLAB® PICkit™ 5 debugger in conjunction with MPLAB X IDE and associated debug tools, developers can set breakpoints, step through code, monitor variables, and inspect peripheral registers in real-time. This stage also involves testing wireless communication (Wi-Fi® and RNBD), verifying MQTT message flow, and evaluating the performance and responsiveness of the embedded Wizard–based GUI. Effective debugging and validation are critical to ensure the system behaves predictably under various runtime conditions.

Information

Ensure the hardware is set up as outlined here.

Debugging Application Project on MPLAB® X IDE

You can debug either a project you have created or one that is available on GitHub.
To debug a project from GitHub, start by cloning the repository using the following Git command:

Information

After cloning the repository, follow the steps below to proceed with debugging.

Open the project in MPLAB X IDE.
Open Project

Back to Top


In the Projects pane, right-click on the project and select Properties from the menu. The Projects Properties dialog box opens.

Project Properties

Back to Top


Ensure SAM9X75D2G is selected as hardware tool to program/debug the application.

Back to Top


In the Connected Hardware Tool drop-down menu, select the PICkit 5 debug probe and click the Apply button.

​You must have the host computer running MPLAB X IDE connected to MPLAB PICkit 5 to see the debugger available in the drop-down menu.

Select Device

Back to Top


In the Categories pane, select PICkit 5.

Back to Top


In the Option categories drop down box, select Communications.

Back to Top


Select the Interface as JTAG.

select JTAG

Back to Top


In the Categories pane, select Bootstrap.

Observe that Use bootstrap is selected and the pre-compiled version of the at91bootstrap.elf is selected. (The pre-complied at91bootstrap.elf can be found in the project directory of the downloaded project).

​While in Debug mode, the second-stage bootloader, at91bootstrap, is used by MPLAB X IDE to initialize DRAM so that it can continue loading the MPLAB Harmony v3 project binary (harmony.bin). Once the project has been loaded onto the SAM9X75 Curiosity Wireless Kit, MPLAB X IDE can be used to run and debug the application.

bootstrap elf

Back to Top


Click the Apply and OK buttons.

At this point you have configured the MPLAB Harmony v3 project within MPLAB X IDE. In the next step, you will build the project for debugging.  

Back to Top


Build the project.

 Click on the Debug Project icon on the toolbar.

The project will build with debugging parameters. Load the application binary to the SAM9X75-Curiosity, and halt at main. Once the build is complete and the application binary is loaded into the target, the toolbar expands to show additional debugging icons.

MPLAB X IDE uses at91bootstrap to initialize the SAM9X75 and then exits without loading any additional binary files to SDRAM. MPLAB X IDE then loads the application program to SDRAM. For more information, see the SAM9X75 Boot Process page.

Back to Top


Click the Continue,  Step In or Step Out  buttons to debug the project.

Debug

Back to Top


Observe the debug messages displayed on the console:

debug message

Back to Top


If you stop a debug session you must press the Reset button on the SAMA9X75-Curiosity to initiate the boot process before launching another debug session.

Back to Top


MPLAB X IDE does not create the .bin file by default. So, we need to use post build commands to generate the .bin file.

Go to Project Properties > Building. Enable the Execute this line after build option and insert the following command.

Information

${MP_CC_DIR}/xc32-objcopy -O binary ${DISTDIR}/${PROJECTNAME}.${IMAGE_TYPE}.elf ${DISTDIR}/harmony.bin

Post Build Step

Build the project. The bin file output can be found in the following path: <your_project>.X\dist\..\production\
Harmony Binaries

 

Back to Top


To test the MPLAB Harmony IoT application, click Continue on the debug window and follow the steps 9-15 here.

Back to Top

Summary

In this training, you have learned how to debug an MPLAB Harmony v3 IoT application example using MPLAB X IDE on the SAM9X75 Curiosity Wireless Kit. 

Back to Top

What’s Next?

Back to Top