Arm® TrustZone® Technology Getting Started Application on PIC32CK SG01: Step 3
Configure the Switch Button 0 Pin and Switch Button 1 with the Secure External Interrupt Controller (EIC) to Generate an Interrupt.
In this step, the switch button will be configured as per the BUTTON0 and BUTTON1 shown in the PIC32CK SG01 Curiosity Ultra Development Board schematic. See Figure 1 and Figure 2.
USER BUTTON 0: Button0 is configured to change the LED Sampling rate.

Figure 1

Figure 2
USER BUTTON 1: Button1 is configured to toggle between the display of LED Sampling rate and Temperature sampling rate, and vice-versa.

Figure 3

Figure 4
In MPLAB® Code Configurator (MCC), select the Pin Settings tab and then scroll down and configure the pins as follows:
- Enable EIC_EXTINT10 on PB26 (Pin #64) as Secure mode and add a Custom Name as "SW0".
- Enable EIC_NMI on PD02 (Pin #121) as Secure mode and add a Custom Name as "SW1".

Figure 5

Figure 6
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.

Figure 7
Configure the EIC block to generate an interrupt every time the user presses the switch SW0 and switch SW1. Switch SW0 press changes the periodicity of the LED toggling rate or the Temperature sampling rate. Switch SW1 press toggles from Basic Functionality to Extended Functionality and vice-versa. Enable filter functionality to avoid electrical noise on the switch pin as shown in the following image.

Figure 8
Configure LED Pin in Secure Mode.
In this step, the user LED0 and user LED1 will be configured as shown in the PIC32CK SG01 Curiosity Ultra Development Board schematic. See Figure 9 and Figure 10.
User LED0: LED0 is configured to notify either the periodicity of the LED toggling rate or the periodicity of the temperature sampling rate as per Switch SW0 press.

Figure 9

Figure 10
User LED1: LED1 is configured to notify whether the last five temperatures are fetched from EEPROM and displayed on the terminal.

Figure 11

Figure 12
In MCC, select the Pin Settings tab and then scroll down and configure the following:
- Enable GPIO on PD20 (Pin #133) as Secure mode and add a Custom Name as "LED0".
- Enable GPIO on PB25 (Pin #63) as Non-Secure mode and add a Custom Name as "LED1".
Both of the pins are configured as an output pin for LED functionality. See Figure 13.

Figure 13