MPLAB® Harmony v3 is now configurable through MPLAB Code Configurator (MCC). Although the instructions in this tutorial are for the MHC, the flow and experience of creating a project, configuring peripherals, and generating code using MCC are similar. Refer to the links below for specific instructions to use MPLAB Harmony v3 with MCC.
This tutorial shows you how to migrate an application from Advanced Software Framework (ASF) to MPLAB Harmony v3 software framework using 32-bit Arm® Cortex®-based M0+ PIC32CM MC microcontroller.
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 Harmony Configurator (MHC) 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.
The application makes use of the PIC32CM MC Curiosity Development Board and the I/O1 Xplained Pro Extension Kit (sold separately).
The application reads the current room temperature from the temperature sensor and light level from the light sensor on the I/O1 Xplained Pro Extension and sends it to the console.
This training module will implement the same application and will also demonstrate the callback feature.
The application you create will utilize:
- SERCOM (as I²C) PLIB to read the temperature from a temperature sensor.
- SERCOM (as Universal Synchronous Asynchronous Receiver Transmitter (USART)) PLIBs and STDIO library to print the temperature values on a COM (serial) port terminal application running on a PC.
- The ADC peripheral library is used to read data from the light sensor.
There are two approaches for this tutorial:
- Create the project from scratch:
- Use the provided source files and step-by-step instructions below.
- Use the solution project as an example:
- Build the solution project and download it to the PIC32CM MC Curiosity Development Board to observe the expected behavior.
- Create an MPLAB X IDE Harmony v3 project for a PIC32CM MC MCU from scratch.
- Use MHC to configure and generate Harmony v3 Peripheral Library code for I²C, USART, and ADC peripherals.
- Use the Harmony v3 Peripheral Library Application Programming Interfaces (APIs) to implement the application.
|Tool|| About|| Purchase|
PIC32CM MC00 Curiosity Pro
The Curiosity series evaluation kits include an onboard Embedded Debugger (EDBG). No external tools are necessary to program or debug the PIC32CM1216MC00048. For programming or debugging, the EDBG connects to the host PC through the USB micro-B connector on the PIC32CM MC Curiosity Development Board.
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.
| Windows|| Linux|| Mac OSX|
Integrated Development Environment
For this lab, download the following repositories from GitHub:
- CSP: The following table shows the summary of contents.
|apps||Example applications for CSP library components|
|arch||Initialization and starter code templates and data|
|docs||CSP library help documentation|
|peripheral||Peripheral library templates and configuration data|
- DEV_PACKS: The following table shows the summary of contents.
|Microchip||Peripheral register specific definitions|
|arm||Core Specific Register Definitions (CMSIS)|
- MHC: The following table shows the summary of contents.
|doc||Help documentation and licenses for libraries used|
|np_templates||New Project templates for supported toolchains|
|*.jar||Java implementations of MHC modules|
|mhc.jar||Main Java executable (run: java -jar mhc.jar -h)|
|runmhc.bat||Windows cmd batch file to run standalone MHC Graphical User Interface (GUI)|
- Use the MPLAB Harmony 3 Content Manager (MHCM) to download the repositories.
This lab shows you how to create an MPLAB Harmony v3 project from scratch. You will configure and generate Harmony v3 peripheral library code for the I²C, USART, and ADC peripherals by considering the SAMC21 ASF example application.
The application flow is as follows:
- The application registers as an I²C callback with a temperature sensor and submits a request to read the temperature value.
- I²C notifies the application with an event after successfully reading the temperature.
- The application converts the temperature value read from the sensor to a readable format (Fahrenheit).
- Meanwhile, ADC is enabled to read and convert the light sensor value from the light sensor on the IO1 Xplained Pro board.
- After the ADC conversion, the temperature and light sensor value are printed on the console continuously.
Lab Source Files and Solutions
This ZIP file contains the completed solution project for this lab. It also contains the source files needed to perform the lab by following the step-by-step instructions (see the "Procedure" section of this page).
The contents of this ZIP file need to be placed in a folder of your choice.
- The project location of a Harmony v3 project is independent of the location of the Harmony Framework path (i.e., you need not create or place a Harmony v3 project in a relative path under the Harmony v3 framework folder). The project can be created or placed in any directory of your choice. This is true because when created, a Harmony v3 project generates all the referred source and header files and libraries (if any) under the project folder.
- The point above contrasts with the Harmony v2 project location. In Harmony v2, the project was supposed to be created in a location under the Harmony framework.
- pic32cm_mc_curiosity_getting_started contains the lab solution (in the firmware folder) and source files (in the dev_files folder).
- The dev_files folder contains subfolder pic32cm_mc00_curiosity_pro, which contains application source files and other support files (if any) required to perform the lab (see "Procedure" section below).
- The firmware folder contains the completed lab solution project. It can be directly built and downloaded on the hardware to observe expected behavior.
Note: All steps must be completed before you are ready to build, download, and run the application.
- Step 1.1 - Verify Whether MHC Plug-in is Installed in MPLAB X IDE
- Step 1.2 - Create MPLAB Harmony v3 Project Using MPLAB X IDE
- Step 1.3 - Configure Clock Settings
- Step 2.1 - Configure I²C Peripheral Library, and I²C Pins
- Step 2.2 - Configure USART Peripheral Library, STDIO, USART Pins, and link STDIO library
- Step 3.1 - Configure Analog-to-Digital Converter (ADC) Peripheral Library (PLIB)
- Step 3.2: Configure Supply controller (SUPC)
Table of Contents