Create Your First Motor Control Application Using MPLAB® Harmony v3: Step 3

Last modified by Microchip on 2023/11/15 12:40

Configure Switch Button Pin with EIC

Add the External Interrupt Controller (EIC) to the project.

Under the Device Resources tab, expand Peripheral > EIC. Select and double-click on EIC to add the EIC module to the project.

Expanding Peripheral > EIC under Device Resources tab

Back to top

Once it is successfully added, EIC will be listed under the Project Resources tab and the Project Graph.

Project Resources tab and the Project Graph

Back to top

When a module is added to the project graph, MPLAB® Code Configurator (MCC) automatically enables the clock to the module. The default EIC clock source is Generic Clock Controller 1 (GCLK1). You can verify the clock source using the Clock Configuration view.

Back to top

Go back to the project graph and configure the EIC block as shown in the accompanying image to generate an interrupt on every switch press (S2 and S3) and enable debounce functionality on switch pins.

Enabling debounce functionality on switch pins

Back to top

Select the Pin Settings tab and configure PD09 and PD10 as EIC Switch input pins as shown in the accompanying image.

Pin Settings tab


EIC channel 4 (EIC_EXINT4) # PIN PD09 and EIC channel 5 (EIC_EXINT5) # PIN PD10 are selected here. Because switches S2 and S3 of MCLV2 board are connected to these specific EIC channel pins.

This information is available in Chapter 1, "PIM to MCU Mapping" of "ATSAME54 100-Pin Motor Control Plugin Module Information Sheet"

Back to top

Configure LED Pin

Open the MCC Pin Settings tab and configure PB26 (LED0) and PB27 (LED1) pins as GPIO output.

MHC Pin Settings tab

This application uses two LEDs as indicators of Motor START state (LED0) and Motor REVERSE direction (LED1).

Pin PB26 and pin PB27 are selected because LEDs (D2 and D17) of the MLCV2 board are connected to these specific pins.

The final project graph will be as shown in the accompanying image:

The final project graph

Back to top