Step 6: Build, Program and Observe the Outputs
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.
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.
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.
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.
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.
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.
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.
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.