Getting Started With MPLAB® Harmony v3 Peripheral Libraries on PIC32CM JH (Arm® Cortex®-M0+) MCUs: Step 3

Last modified by Microchip on 2025/09/29 09:43

Information

Note: This video shows the General Purpose Input/Output (GPIO) configuration for the application using MPLAB® Code Configurator (MCC).

Configure Switch Button Pin With External Interrupt Controller (EIC) to Generate an Interrupt

In this step, the switch button will be configured as per the USER BUTTON shown in the board schematic.

USER BUTTON: Button is configured to change the LED Sampling rate.

User Button Schematic

User Button Schematic

In MCC, select the Pin Settings tab and then scroll down and configure the pins as follows:

  • Enable EIC_EXTINT0 on PB16 to detect the switch press.

Pin Setting tab

Note: Internal pull-up is enabled to avoid false edge detection as there is no external pull-up on the board.

Select the Project Graph tab. Under the Device Resources tab, expand Harmony > Peripherals > EIC.

Select and double-click on EIC to add the EIC module to the project.

Project Graph

                                                                                                             

Configure the EIC block to generate an interrupt every time the user presses the switch. Switch press changes the periodicity of the LED toggling rate. Enable filter functionality to avoid electrical noise on the switch pin as shown in the accompanying image.

EIC Peripheral Library

 


Configure the LED Pin

In this step, the user LED  will be configured as shown in the PIC32CM JH-Value Line Curiosity Nano + Touch Evaluation Kit schematic.

User LED: LED is configured to notify either the periodicity of the LED toggling rate or the periodicity of the sampling rate as per switch press.

PIC32CM JH-Value Line Curiosity Nano + Touch Evaluation Kit schematic

In MCC, select the Pin Settings tab and then scroll down and configure the following:

  • Enable GPIO on PB17 (Pin #40) and add a Custom Name as "LED".

Both of the pins are configured as an output pin for LED functionality as shown in the accompanying image.

Pin Setting tab

Note: The LED on the PIC32CM JH-Value Line Curiosity Nano + Touch Evaluation Kit is active Low. Configure the LEDs in the default OFF state by configuring the latch value to logic Low.

Back to Top