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

Step 6: Build, Program and Observe the Outputs

1

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.

hw_setup6.png

2

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.

compiler_setup.png

3

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

clean_and_build_icon.png

4

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

make_and_program.png

The lab will build and program.

5

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

com_port_setup1.png

6

Change the baud rate to 115200.

com_port_setup2.png
baud_rate_setup.png

7

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.

a

Press the switch SW1 on the Curiosity PIC32MZ EF 2.0 Development Board to change the periodicity of the timeout to one second.

b

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.

c

Press the switch SW3 on the Curiosity PIC32MZ EF 2.0 Development Board to switch the toggling LED from LED1 to LED3.

d

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.

e

Press the switch SW1 on the Curiosity PIC32MZ EF 2.0 Development Board to switch back the toggling LED from LED3 to LED1.

result7.png

8

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.

hw_setup4.png

9

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.

hw_setup5.png

10

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.

step_6_hw_setup1.jpg

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.

a

Press the switch SW2 on the Curiosity PIC32MZ EF 2.0 Development Board to read and print the Temperature from the Temperature Sensor.

b

The temperature read is displayed on a serial console on a periodical basis.

c

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.

d

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.

e

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.

result7_extended.png

11

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

temp_sensor_placement.jpg

12

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.

user_button_placement.jpg

13

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.

result_sw3_led3_toggling.png

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).

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.

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.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.