Step 3.1: Configure Switch Button Pin with the External Interrupt Controller (EIC) to Generate an Interrupt
In this step, the switch button will be configured as shown in the following image.
1
In MPLAB® Code Configurator (MCC), select the Pin Settings tab and then scroll down to the PORT pin PA15 (Pin Number 32) in the Pin ID column and configure PA15 as an external interrupt pin for switch functionality as shown in the following image. Internal pull-up is enabled to avoid false edge detection as there is no external pull-up on the SAM D21 Xplained Pro Evaluation Kit.
2
Select the Project Graph tab.
Step 3.2: Configure LED Pin
In this step, the user LED will be configured as per the following image.
1
Select the MCC Pin Settings tab and then scroll down to the PORT pin PB30 (Pin Number 59) in the Pin ID column and configure PB30 as an output pin for LED functionality as shown in the following image.
The LED on the SAM D21 Xplained Pro Evaluation Kit is active low. Configure the LED in default OFF state by configuring the latch value to logic "High".
Step 3.3: Rename the Default Main File
1
Under the Project Graph tab, click on System, and configure as shown in the following image to give the name of your liking to the default template main file generated by MCC.
The name of the default main.c is changed to main_d21.c to indicate that the referred main.c is for the SAM D21 getting started training module.