Getting Started With MPLAB® Harmony v3 Peripheral Libraries on PIC32CM JH (Arm® Cortex®-M0+) MCUs: Step 6

Last modified by Microchip on 2025/09/29 09:43

Information

Note: This video shows how to compile the project and view the results.

Build, Program, and Observe the Outputs

Connect the PIC32CM JH VL Curiosity Nano+ Touch Evaluation Kit to the host PC as a USB device through a Type-A male to USB Type-C® cable connected to USB Type-C (Debug USB) port.

PIC32CM JH VL Curiosity Nano+ Touch Evaluation Kit

 

Go to File > Project Properties and select the connected hardware tool as PIC32CM JH VL Curiosity Nano+ Touch Evaluation Kit (PIC32CM6408JH00064) and the XC32 compiler v4.60, then click OK.

Project Properties window

Program the PIC32CM JH VL Curiosity Nano+ Touch Evaluation Kit using the Make and Program Device Main Project option as shown.

Clean and Build button

Now, open the Tera Term or Putty terminal application on your PC (from the Windows® Start menu by pressing the Start button). Select the Serial Port as shown.

Tera Term New Connection window

Once the COM port is connected, click on Setup > Serial port. In the Tera Term additional settings window that appears, change the baud rate to 115200.

Setup > Serial Port in the COM53 - Tera Term VT window

Baud Rate Setup in the Tera Term: Serial port setup and connection window

Every subsequent pressing of the switch SW200 on the PIC32CM JH VL Curiosity Nano+ Touch Evaluation Kit changes the periodicity of the timeout to 2 seconds (s), 4s, 500 milliseconds (ms), and back to 1s in cyclic order as shown.

Results 1

Additionally, observe the LED toggling at a 500-ms interval on the PIC32CM GV-VL CNANO board.

PIC32CM GV-VL CNANO Board

 

Back to Top

Results

The application successfully toggled an LED on the development board every 500 ms using the Real-Time Clock (RTC). A message indicating the current LED toggling rate was transmitted over the serial terminal through a Universal Synchronous Asynchronous Receiver Transmitter (USART) interface using Direct Memory Access (DMA). On pressing the user switch (SW200), the LED toggling rate dynamically changed in sequence to 1 second, 2s, and 4s, and then cycled back to 500 ms. Each time the user switch was pressed, a corresponding message was displayed on the serial terminal reflecting the updated toggling rate. The LED toggled each time the RTC period elapsed, and the message was printed to the serial terminal using non-blocking Direct Memory Access (DMA) transfer, ensuring real-time response.

Back to Top

Analysis

You have successfully implemented a real-time embedded application using MPLAB® Harmony v3 on a Microchip microcontroller (MCU). This application used core features such as the RTC, External Interrupt Controller (EIC), Direct Memory Access Controller (DMAC), and USART, all configured through MPLAB Harmony-generated Peripheral Libraries (PLIBs). The RTC was set up to periodically trigger at configurable intervals (500 ms to 4s), and the EIC captured user switch inputs to modify the sampling rate on the fly. DMA was employed to offload UART data transmission, enhancing CPU efficiency. This modular, interrupt-driven design structure allows for efficient handling of user interaction and peripheral communication with minimal CPU overhead. In this application, MPLAB Code Configurator (MCC) was used to configure the system clock, RTC, EIC, USART, and DMAC. The pin configurator was used to set the LED and switch pins appropriately. The software architecture is designed for scalability, maintainability, and minimal power usage by relying on event-driven behavior instead of polling.

Back to Top

Conclusions

This project provided practical experience in building an interrupt-driven embedded application using MPLAB Harmony v3 on a PIC32CM JH VL Curiosity Nano + Touch Evaluation Kit. It covered real-time peripheral interaction, dynamic user control, and non-blocking serial communication using DMA. This knowledge is transferable and can be extended to other MCUs in the PIC32CM JH family, allowing you to develop similar applications with enhanced peripherals or memory configurations. As a next step, you can build upon this foundation by integrating additional peripherals like sensors, touch interfaces, or cryptographic functions depending on your end application.

Back to Top