Step 2: Configure Pins for Switch and LED

Last modified by Microchip on 2026/06/26 07:36

Configure External Interrupt Controller (EIC) PLIB for Switch Button

Note: Create an MPLAB® Harmony v3 project using MPLAB X IDE. Refer to Lab 1, Step 2 for detailed project creation instructions. After the project is created, follow these steps to configure the EIC peripheral and mechanical switch, SW1.

After launching MPLAB Code Configurator (MCC), navigate to the Device Resource tab. In the Device Resources panel, expand Libraries > Harmony > Peripherals > EIC. To add the EIC Peripheral Library (PLIB) to your project graph, either double-click on EIC or drag and drop it into the project graph area.

Dragging EIC to the project graph
             

Select the EIC Peripheral Library in the Project Graph. The configuration options will appear on the right side of the interface. Enable EIC Channel 2, set the security mode to NON-SECURE, and enable the interrupt. For External Interrupt 2, choose Rising Edge Detection as the edge selection. Then, enable both the Debounce and Filter options.

Configuration Options pane

Note: The mechanical switch connected to pin PA23 is mapped to EIC Channel 2, as specified in the user guide and device data sheet. Since EIC channels are hardware‑mapped to specific pins, selecting Channel 2 ensures correct interrupt routing for pin PA23.

User Guide Section 4.2.2


Pin Configuration for Switch and LED

Open the Pin Configuration tabs by clicking Project Graph > Plugins > Pin Configuration.

Project Graph pane

Select the MCC Pin Settings tab and sort the entries by Ports, as shown in the accompanying image.

Pin Setting tab

Scroll down to Pin Number 32 (Pin ID: PA23). Configure the pin function as EIC_EXTINT2, enable the internal pull-up resistor and set the Security Mode to NON-SECURE.

Pin Setting tab

Configure PA15 as a General-Purpose Input/Output (GPIO) pin. Assign the appropriate pin name and specify the direction and latch settings required for LED operation.

Pin Setting tab

Note: For instructions on selecting pins for a mechanical switch, refer to Lab 2, which provides detailed guidance on choosing GPIO pins for both switch SW1 and LED.


Arm® TrustZone® for Armv8-M

Go to Plugins drop-down options in Project Graph and then select Arm TrustZone for Armv8-M.

Project Graph pane

In the Peripheral Configuration > Peripherals section of the Arm TrustZone for Armv8-M window. By default, the EIC peripheral is a Mix-Secure Peripheral. This allows you to individually assign each external interrupt to the secure or non-secure applications on the PIC32CM LS00 Curiosity Nano+ Touch Evaluation Kit.

Pin Configuration tab

Back to Top