PreLAB: External Interrupt

Name:

ID:

I. Introduction

In this tutorial, we will learn how to use External Interrupt. We will create functions that capture the falling edge trigger by pushing a button using an external interrupt.

The objectives of this tutorial are how to

  • Configure External input (EXTI) interrupt with NVIC

  • Create your own functions for configuration of interrupts

Hardware

  • NUCLEO -F411RE

Software

  • VS code, CMSIS, EC_HAL

Documentation

II.Basics of External Interrupt (EXTI)

A. Register List

List of external interrupt (EXTI) registers used in this tutorial [Reference Manual ch7, ch10.2]

Register List

B. Register Setting

(Digital Input Setting)

  • Enable GPIO peripheral clock RCC->AHB1ENR

  • Configure DigitalIn pin

(EXTI Setting)

  • Enable SYSCFG peripheral clock. RCC->APB2ENR

  • Connect the corresponding external line to GPIO SYSCFG->EXTICR

  • Configure the trigger edge. EXTI->FTSR/RTSR

  • Configure Interrupt mask EXTI->IMR

  • Enable EXTI. EXTI->IMR

(NVIC Setting)

  • Configure the priority of EXTI interrupt request. NVIC_SetPriority()

  • Enable EXTI interrupt request. NVIC_EnableIRQ()

(EXTI Use)

  • Create user codes in handler EXTIx_IRQHandler()

  • Clear pending bit after interrupt call

III. Tutorial

A. Register Configuration

Fill in the blanks below

  1. Pin Initialization & Set LED and Push-button

  • LED Pin : Port B Pin 12 / Output / Push-Pull / No Pull-Up & No Pull-Down

  • Push-Button: Port A Pin 4 / Input / No Pull-Up & No Pull-Down

  1. Enable Peripheral Clock: SYSCFGEN

  • RCC_APB2ENR: Enable SYSCFG

RCC_APB2ENR
  1. EXTI Initialization & Connect Push-button to EXTI line

  • SYSCFG_EXTICR2: Connect PA_4(push-button) to EXTI4 line

EXTICR
  • EXTI_FTSR: Enable Falling Trigger

FTSR
  • EXTI_IMR: Interrupt NOT masked (Enable)

IMR

B. Programming

This is an example code for toggling LED on/off with the button input trigger (EXTI)

Fill in the empty spaces in the code.

Procedure

  • Name the project as TU_EXTI by creating a new folder as tutorial\TU_EXTI

  • Download the template code

  • Fill in the empty spaces in the code.

  • Run the program and check your result.

  • Your tutorial report must be submitted to LMS

DO NOT use ecEXTI2_student.h for this tutorial.

You MUST write your name on the source file inside the comment section

Last updated

Was this helpful?