MPLAB® Harmony v3 Peripheral Libraries on PIC32CM GV-VL (Arm® Cortex®-M0+) MCUs: Step 6
The PIC32CM GV VL Curiosity Nano+ Touch Evaluation Kit allows the Embedded Debugger (nEDBG) to be used for debugging. Connect the Type-A male to USB Type-C® cable to the debug USB port to power and debug the PIC32CM GV VL Curiosity Nano+ Touch Evaluation Kit.
In MPLAB® X IDE, navigate to File > Project Properties, and ensure that PIC32CM GV-VL Curiosity Nano EDBG is chosen as the debugger under Connected Hardware Tools, and XC32 (v4.60) is selected as the Compiler Toolchain for XC32.
Program your application to the device by clicking on the Make and Program button as shown in the accompanying image.
Check whether the lab builds and programs successfully, and verify the build results in the output dialog box.
Now, open the Tera Term terminal application on your PC (from the Windows® Start menu by pressing the Start button). Select the Serial Port as shown in the accompanying image.
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, as shown in the accompanying image.
You should see the LED toggling rate displayed on the terminal every 500 milliseconds.
Additionally, observe the LED toggling at a 500-millisecond interval on the PIC32CM GV-VL CNANO Board.
Press the SW200 switch on the PIC32CM GV-VL Curiosity Nano to change the default sampling rate to 1 second. You will also notice that the LED toggling interval has changed to 1 second.
Every subsequent pressing of the SW200 switch on the PIC32CM GV-VL CNANO Kit changes the default sampling rate to 2 seconds, 4 seconds, 500 milliseconds, and back to 1 second in cyclic order as shown in the accompanying image.
Results
You observed that the application toggled an LED on the development board every 500 milliseconds using the Real-Time Clock (RTC). A message indicating the current LED toggling rate was printed on the serial terminal through a Universal Synchronous Asynchronous Receiver Transmitter (USART) interface using STDIO. On pressing the user switch (SW200), the LED toggling rate dynamically changed in sequence to 1 second, 2 seconds, and 4 seconds, and then cycled back to 500 milliseconds. Every 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 Standard Input/Output (STDIO).
Analysis
You have successfully created your first application using MPLAB Harmony v3 on a PIC32CM GV-VL CNANO microcontroller. Your application used all the fundamental elements that go into building a real-time application. Your application successfully toggled the LED periodically and displayed it periodically over a serial terminal on a PC. The application also took user input by pressing a switch on the development board.
In this application, you used MPLAB Code Configurator (MCC) to configure the PIC32CM GV-VL CNANO and also used the MPLAB Harmony v3 framework. You used the clock configurator to set up the CPU clock and timer (RTC) clock. You configured SERCOM 2 as USART, RTC, and External Interrupt Controller (EIC) Peripheral Libraries (PLIBs). You also configured the STDIO using the SERCOM 2 USART peripheral. You used the pin configurator to set up the pins for LED and switch functions.
Conclusions
This tutorial has equipped you with the necessary training to configure and utilize the essential components needed to build a real-time application on a PIC32CM GV-VL CNANO microcontroller with the MPLAB Harmony v3 framework. As your next step, you can customize this application and reconfigure some of the components used in this tutorial. Additionally, you have the option to add new components (PLIBs, etc.) to enhance this application to realize your end application.