Getting Started With MPLAB® Harmony v3 Peripheral Libraries on PIC32CM GV-VL (Arm® Cortex®-M0+) MCUs

Last modified by Microchip on 2025/10/09 16:08

Objective

This tutorial shows you how to create a basic peripheral library application on a PIC32CM GV-Value Line Curiosity Nano+ Touch microcontroller (MCU) using MPLAB® Harmony v3 software framework.

MPLAB Harmony v3 is a flexible, fully-integrated, embedded software development framework for 32-bit microcontrollers (MCUs) and microprocessors (MPUs). MPLAB Harmony v3 includes the MPLAB Code Configurator (MCC) tool, a set of modular Peripheral Libraries (PLIBs), drivers, system services, middleware, and numerous example applications, all of which are designed to help you quickly and easily develop powerful and efficient embedded software for Microchip’s 32-bit PIC® and SAM devices.

This tutorial demonstrates how to utilize MCC to create an application that provides a foundation for developing applications on PIC32CM GV-VL MCUs using the MPLAB Harmony v3 software framework.

The application makes use of the PIC32CM GV-Value Line Curiosity Nano+ Touch Evaluation Kit.

The application showcases an LED that toggles based on a timeout and prints the LED toggling rate on a serial terminal. The periodicity of the timeout will change from 500 milliseconds (ms) to 1 second (s), 2s, 4s and back to 500 ms each time the mechanical switch on the PIC32CM GV VL Curiosity Nano+ Touch Evaluation Kit is pressed.

The application you create will utilize:

  • Real-Time Clock (RTC) PLIB to periodically toggle the LED
  • SERCOM (as Universal Synchronous Asynchronous Receiver Transmitter (USART)) PLIB with STDIO extension to print the LED toggling rate on a serial COM port terminal application running on a PC
  • PORT PLIB to toggle the LED
  • External Interrupt Controller (EIC) PLIB to change the periodicity of LED toggle and print using SWITCH press event

The lab will also demonstrate the use of callback functions.

Two Ways to Use This Tutorial

  1. Create the project from scratch:
    • Use the provided source files and step-by-step instructions below.
  2. Use the solution project as an example:
    • Build the solution project and program it to the PIC32CM GV-Value Line Curiosity Nano+ Touch Evaluation Kit to observe the expected behavior.

Back to Top

Lab Objectives

  1. Create an MPLAB X Integrated Development Environment (IDE) Harmony v3 project for a PIC32CM GV-VL microcontroller from scratch.
  2. Use MCC to configure and generate Harmony v3 PLIBs code for RTC, USART, EIC, and PORT peripherals.
  3. Use Harmony v3 PLIB Application Programming Interfaces (APIs) to implement periodic LED toggling with rate change on switch press and display the current toggle rate on a serial terminal.
  4. Demonstrate the use of interrupt-driven callbacks to handle RTC and switch events in real time.

Back to Top

Reference Materials

Apart from the hardware tools listed above, the following items are required:

  • USB Type-A male to USB Type-C® male cable for programming and debugging.

Note: The Curiosity Nano series development kits include an on-board Nano Debugger (nEDBG). No external tools are necessary to program or debug the PIC32CM3204GV00064. For programming /debugging, the nEDBG connects to the host PC through the USB Type-C connector on the PIC32CM GV-VL Curiosity Nano+ Touch Evaluation Kit.

Note: This project has been verified to work with the following versions of software tools:

Because we regularly update our tools, occasionally you may discover an issue while using the newer versions. If you suspect that to be the case, we recommend that you double-check and use the same versions that the project was tested with.

In such cases, if you are using an existing project, the MCC v5.6.2 Content Manager will automatically download the versions specified in the project's manifest file.

You will use the MPLAB X IDE MCC Content Manager for MPLAB Harmony projects to download the following repositories from GitHub:

  • CSP: The following table shows the summary of contents.
FolderDescription
appsExample applications for Chip Support Package (CSP) library components
archInitialization and starter code templates and data
docsCSP library help documentation
peripheralPLIB templates and configuration data

Connection Diagram

Connect the PIC32CM GV-Value Line Curiosity Nano+ Touch Evaluation Kit to the host PC as a USB device using a Type-A male to USB Type-C cable, with the Type-C end plugged into the Debug USB port. This debug USB port is used for debugging and powering up the device.
Connection Diagram

Back to Top

Overview

This lab shows you how to create an MPLAB Harmony v3 project from scratch, and how to configure and generate:

  • MPLAB Harmony v3 peripheral libraries code for the RTC peripheral
  • MPLAB Harmony v3 peripheral libraries code for the EIC and PORTS peripherals
  • MPLAB Harmony v3 peripheral libraries code for the USART peripheral
Information

Note: This video shows the overview of the getting-started-application project.

It demonstrates how to toggle an LED at regular intervals and display the current toggling rate on the serial terminal. The interval (timeout period) should cycle through 500 ms, 1s, 2s, 4s, and then return to 500 ms each time the mechanical switch on the PIC32CM GV VL Curiosity Nano+ Touch Evaluation Kit is pressed.

The application initializes the clock, PORT, and other peripherals (configured through MCC) by calling the function SYS_Initialize.

The application registers callback event handlers for RTC and EIC PLIBs. The callback event handlers are called back by the PLIBs when the RTC expires and LED sampling rate changes when the event occurs.

Event Sequence

Note:

  1. A callback event handler for EIC is triggered when the SW200 is pressed, allowing the application to update the LED toggle rate.
  2. The RTC peripheral is used for implementing the time period instead of the timer peripheral. This is done to demonstrate how to configure and use RTC peripherals in an application.

The application checks whether the configured RTC timer period has expired. Each time the timer period expires, the callback event handler sets a flag in the rtcEventHandler.

The application then clears the isRTCExpired flag, toggles the LED, and prints the LED toggling rate to the console.

The application also monitors the SW200 switch for user input. When a press is detected, it changes the LED toggle sampling rate from the default 500 ms to 1s. With each subsequent press, the sampling rate is updated to 2s, then 4s, and finally cycles back to 500 ms. The LED toggling rate is adjusted with every switch press, as illustrated in the accompanying image.

LED Toggling Rate

 

Back to Top

Lab Source Files and Solutions

Download the project file.

This ZIP file contains the completed solution project for this lab. It also contains the source files needed to perform the lab as per the following step-by-step instructions (see the "Procedure" section on this page).

The contents of this ZIP file need to be placed in a folder of your choice.

  • The project location of an MPLAB Harmony v3 project is independent of the location of the MPLAB Harmony framework path (i.e., you don't need to create or place an MPLAB Harmony v3 project in a relative path under the MPLAB Harmony v3 framework folder).

Note: Windows® Operating System (OS) has a maximum path length of 260 characters and a command-line limitation for Windows OS of 8191 characters. As a workaround, consider moving the project folder to C:/ drive to reduce the project path length, then open it in MPLAB X IDE to build the project.

  • The previous point is true because when created, an MPLAB Harmony v3 project generates all the referred source and header files and libraries (if any) under the project folder.

Extracting the ZIP file creates the following folders:

  • getting_started_pic32cm_gv_vl_cnano contains the lab solution and source files (in the dev_files folder).
    • The project folder contains the completed lab solution project which consists of firmware. It can be directly built and programmed on the hardware to observe expected behavior.

Back to Top

Procedure

Information

All steps must be completed before you will be ready to build, download, and run the application.

Lab Index

Step 1: Create a Project and Configure the PIC32CM GV-VL CNANO

  • Step 1 - Create MPLAB Harmony v3 Project Using MPLAB X IDE
  • Step 2 - Verify Clock Settings

Step 2: Configure SERCOM 2 (USART) and RTC Peripheral Libraries

  • Step 1 - Configure Real-Time Clock (RTC) Peripheral Library
  • Step 2 - Configure SERCOM 2 (USART) Peripheral Library, STDIO Extensions and USART Pins

Step 3: Configure Pins for Switch and LED

  • Step 1 - Configure Switch Button Pin with EIC to Generate an Interrupt
  • Step 2 - Configure LED Pin

Step 4: Generate Code
Step 5: Add Application Code to the Project
Step 6: Build, Program, and Observe the Outputs

Back to Top