Update and Configure an Existing MHC-based MPLAB® Harmony v3 Project to MCC-based Project: Step 6

Last modified by Microchip on 2023/11/09 09:10

Step 6: Build, Program and Observe the Outputs

The Curiosity PIC32MZ EF 2.0 Development Board allows using the PICkit™ On Board 4 (PKoB 4) for debugging. Connect the Type-A male to Micro-B USB cable to the Micro-B DEBUG USB port to power and debug the Curiosity PIC32MZ EF 2.0 Development Board.

Curiosity PIC32MZ EF 2.0 Development Board


Go to File > Project Properties and make sure that the PKoB 4 is selected as the debugger under the Hardware Tools, and XC32 (v3.00) is selected as the Compiler Toolchain for XC32.

Project Properties, Compiler

Back to Top


Clean and build your application by clicking on the Clean and Build button.

Clean and Build icon

Program your application to the device by clicking on the Make and Program button.

Make and Program icon

The lab will build and program.

Back to Top


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

Tera Term setup

Change the baud rate to 115200.

Tera Term setup

Baud rate setup

Back to Top


Serial port output

An LED (LED1) on the Curiosity PIC32MZ EF 2.0 Development Board toggles on every timeout basis and the default periodicity of the timeout is 500 milliseconds. The LED toggling rate is displayed on the serial terminal.

  1. Press the switch SW1 on the Curiosity PIC32MZ EF 2.0 Development Board to change the periodicity of the timeout to one second.
  2. Every subsequent pressing of the switch SW1 on the Curiosity PIC32MZ EF 2.0 Development Board changes the periodicity of the timeout to 2 seconds, 4 seconds, 500 milliseconds, and back to 1 second in cyclic order.
  3. Press the switch SW3 on the Curiosity PIC32MZ EF 2.0 Development Board to switch the toggling LED from LED1 to LED3.
  4. Every subsequent pressing of the switch SW3 on the Curiosity PIC32MZ EF 2.0 Development Board changes the periodicity of the timeout to 2 seconds, 4 seconds, 500 milliseconds, and back to 1 second in cyclic order.
  5. Press the switch SW1 on the Curiosity PIC32MZ EF 2.0 Development Board to switch back the toggling LED from LED3 to LED1.

Back to Top


LED1 starts toggling when switch SW1 is pressed. The toggling happens on a timeout basis. The periodicity of the timeout will change from 500 milliseconds to 1 second, 2 seconds, 4 seconds, and back to 500 milliseconds every time you press the switch SW1 on the Curiosity PIC32MZ EF 2.0 Development Board.

Curiosity PIC32MZ EF 2.0 Development Board

Back to Top


LED3 starts toggling when switch SW3 is pressed. The toggling happens on a timeout basis. The periodicity of the timeout will change from 500 milliseconds to one second, two seconds, four seconds, and back to 500 milliseconds every time you press the switch SW3 on the Curiosity PIC32MZ EF 2.0 Development Board.

Curiosity PIC32MZ EF 2.0 Development Board

Back to Top


Testing Extended functionality (Optional):
Verify that the temperature sensor (I/O1 Xplained Pro Extension Kit) is connected to J501 (Extension Header 1 (EXT1)) on the Curiosity PIC32MZ EF 2.0 Development Board.

Curiosity PIC32MZ EF 2.0 Development Board and I/O1 board

Note: This is an optional setup required to test extended functionality of the demo. i.e., to read the temperature value and print it on the serial terminal.

Tera Term output

  1.  Press the switch SW2 on the Curiosity PIC32MZ EF 2.0 Development Board to read and print the Temperature from the Temperature Sensor.
  2. The temperature read is displayed on a serial console on a periodical basis.
  3. Press the switch SW1 (toggles LED1) on the Curiosity PIC32MZ EF 2.0 Development Board to change the periodicity of the temperature values displayed on the serial console. The periodicity will be changed between 500 milliseconds, 1 second, 2 seconds, 4 seconds, and back to 500 milliseconds every time the user presses the switch SW1 on the Curiosity PIC32MZ EF 2.0 Development Board.
  4. Press the switch SW3 (toggles LED3) on the Curiosity PIC32MZ EF 2.0 Development Board to change the periodicity of the temperature values displayed on the serial console. The periodicity will be changed between 500 milliseconds, one second, two seconds, four seconds, and back to 500 milliseconds every time the user presses the switch SW3 on the Curiosity PIC32MZ EF 2.0 Development Board.
  5. The LED1 toggles for every 500 milliseconds during the power cycle. The periodicity will not change while switching between SW1 to SW3 or vice versa.
     

Back to Top


You may vary the temperature by placing your finger on the temperature sensor (for a few seconds).

Curiosity PIC32MZ EF 2.0 Development Board temp sensor

Back to Top


LED1 starts toggling when switch SW1 is pressed. The toggling happens on a timeout basis. The periodicity of the timeout will change from 500 milliseconds to 1 second, 2 seconds, 4 seconds, and back to 500 milliseconds every time you press the switch SW1 on the Curiosity PIC32MZ EF 2.0 Development Board.

Curiosity PIC32MZ EF 2.0 Development Board user button

Back to Top


LED3 starts toggling when switch SW3 is pressed. The toggling happens on a timeout basis. The periodicity of the timeout will change from 500 milliseconds to 1 second, 2 seconds, 4 seconds, and back to 500 milliseconds every time you press the switch SW3 on the Curiosity PIC32MZ EF 2.0 Development Board.

Curiosity PIC32MZ EF 2.0 Development Board

Back to Top


Results

You observed that the application toggled an LED (LED1 is toggled when the switch SW1 is pressed and LED3 is toggled when the switch SW3 is pressed) on a timeout basis and printed the LED toggling rate on the serial terminal. The periodicity of the timeout is changed from 500 milliseconds to 1 second, 2 seconds, 4 seconds, and back to 500 milliseconds every time you pressed the switch SW1 or SW3 on the Curiosity PIC32MZ EF 2.0 Development Board. The periodicity has not changed when switching between SW1 to SW3 or vice versa. Also, the demo application has printed the current room temperature periodically when switch SW2 is pressed (the XPRO connector plugged with I/O1 Xplained Pro Extension Kit).

Back to Top

Analysis

You have successfully updated the MHC project using MPLAB® Code Configurator (MCC) on the Curiosity PIC32MZ EF 2.0 Development Board. Your application used all the fundamental elements that go into building a real-time application. Your application successfully toggled LEDs based on your switch, also read temperature sensor values, and displayed them periodically over a serial terminal on a PC. The application also took user input by pressing a switch on the Curiosity PIC32MZ EF 2.0 Development Board.

In this application, you used MPLAB Code Configurator (MCC) to update and configure the GPIO pins for LED and switch functions using the Pin Configurator plugin. You also verified the PLIB configurations, CPU clock, I²C1, UART6, TMR1, Direct Memory Access (DMA) using the DMA configurator and GPIO peripheral libraries. You also generated the code using the MPLAB Code Configurator and added the code built and tested on Curiosity PIC32MZ EF 2.0 Development Board.

Back to Top

Conclusions

This tutorial provided training on how to update and configure an existing MHC-based MPLAB Harmony v3 project to an MCC-based project and also provided steps to configure the GPIO pins for LED and switch functions using the Pin Configuration plugin. You also verified the PLIB configurations, CPU clock and timer (Timer1) clock, I²C1, UART6, TMR1, Direct Memory Access (DMA) using the DMA configurator, and GPIO peripheral libraries. You also generated the code using MCC, extended the code, built and tested it on Curiosity PIC32MZ EF 2.0 Development Board.

Back to Top