Step 2: Configure EIC for Switch in the Non-Secure Region and LED in the Secure Region

Last modified by Microchip on 2026/07/01 09:13

Configure External Interrupt Controller (EIC) PLIB as Non-Secure for the 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 the steps below 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 the project graph, either double-click on EIC or drag and drop it into the project graph area.

​​​​​ Device resource    

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 and set the security mode to NON-SECURE to designate the EIC peripheral as Non-Secure. Enable the interrupt for this channel. For External Interrupt 2, select Rising Edge Detection as the edge type. Then, enable both the Debounce and Filter options.

EIC Peripheral Library​​​​​

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.

                                Mechanical switch for PA23               


Pin Configuration for the Switch and LED

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

Pin configuration

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

Pin settings

Scroll down to Pin Number 32 (Pin ID: PA23). Set the Function to EIC_EXTINT2, enable the Pull Up resistor for this pin, and set the security mode to NON-SECURE.

Pin 32

Configure PA15 as a General-Purpose Input/Output (GPIO) pin. Assign an appropriate pin name, set the Direction to Out, the Latch to High, and the Security Mode to Secure to enable LED operation in the Secure region.

PA15 configuration

Note: For instructions on selecting pins for a mechanical switch and LED, refer to Lab 2, Step 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.

Plug-ins drop down options

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.

Peripheral Configuration

Back to Top