Arm® TrustZone® Technology Getting Started Application on PIC32CK SG01: Step 3

Last modified by Microchip on 2024/03/26 10:39

 

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.

User Button0 Schematic

Figure 1

User button0 schematic

Figure 2

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

User button1 schematic

Figure 3

User LED1 Schematic

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".

Note: Since we are using two Switches (EIC), give a Custom Name for each to differentiate between them. Here "SW0and "SW1 are given as a Custom Name for User Buttons 0 and 1.

EIC pin configuration

Figure 5

EIC pin configuration

Figure 6

Note: Internal pull-up is enabled to avoid false edge detection as there is no external pull-up on the PIC32CK SG01 Curiosity Ultra Development 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.

EIC peripheral adding

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.

EIC Pin configuration

Figure 8

Back to Top


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.
 

user led schematic

Figure 9

User LED0 Schematic

Figure 10

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

User LED Schematic

Figure 11

User LED1 schematic

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.

LED Pin configuration

Figure 13

Note:

  • The LED0 and LED1 on the PIC32CK SG01 Curiosity Ultra Development Board is active low. Configure the LED's in the default OFF state by configuring the latch value to logic High.
  • As per the application project design, the User LED0 must be configured in Secure mode, and by default, this pin is configured as a Secure mode pin by MCC.
  • As per the application project design, the User LED1 must be configured in Non-Secure mode, and by default, this pin is configured as a Secure mode pin by MCC.

Back to Top