Getting Started With MPLAB® Harmony v3 Peripheral Libraries on PIC32CM JH (Arm® Cortex®-M0+) MCUs: Step 3
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.
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.
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.
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.
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.
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.