Assignment #5: EXTI Interrupts

📚 Assignment 5 CMPE2250: EXTI Interrupts

In this assignment, you will explore the following:

  • Configure EXTI lines for multiple GPIO sources
  • Implement interrupt‑driven event handling
  • Separate ISR‑safe logic from main‑loop processing
  • Implement long‑press detection using timing and/or edge detection logic

📋 Overview

  • In this ICA you will explore using EXTI interrupts.

  • You may create a library to facilitate EXTI configuration, but because parameterization of the GPIO ports would be difficult, you might just want to document a single example for future reference.

  • You will use the user button on the Nucleo board (Blue SW) as the source of one of the EXTI interrupts, and the HC-35S Button Board.

  • You will also use the UART 7-segment display to show a counter that increments/decrements every time an EXTI interrupt is triggered.

1️⃣ Preparatory Work:

  • Configure the EXTI lines to capture falling edges on the following PINS:

    • PC13 (User button - Blue SW)
    • PD8 (Button Board SW1)
    • PD9 (Button Board SW4)
  • Configure the user LED LD4 as an output.

  • Every part is incremental so there’s no need to comment out code, but you could use conditional preprocessor blocks as usual to make it easier to test each part of the ICA if you like.

  • You should design your code the most efficient way possible, meaning no sprintf or other expensive functions to convert the counter value to a string for display on the 7-segment should be done inside the ISR. Other simple math such as changing the counters and flags is totally fine, but the conversion to string and display should be done in the main infinite loop.

2️⃣ Part A

  • Have a counter to start at 0000 and increment by 1 every time SW4 is pressed, and decrement by 1 every time SW1 is pressed. The counter should wrap around at 9999 and 0000, meaning it should roll from 9999 back to 0000 and vice versa.

3️⃣ Part B

  • Define an autoRun software flag that will be toggled by the USER button (blue SW). When the flag is set, the counter will automatically increment every second. When the flag is cleared, the counter will only change in response to button presses. You could use any timer to accomplish this, but the SysTick timer is a good choice for this application. No blocking delays are allowed in this part, so you will need to use a timer interrupt or Systick handler to implement the timing for the automatic counter incrementing.

  • Toggle the user User LED LD4 every second when the counter is incrementing automatically, so that it’s easy to see when the counter is in auto‑increment mode.

  • The flag should start at 0 when the program starts, meaning the counter will not automatically increment until the user button is pressed for the first time.

4️⃣ Part C

  • Add functionality such that when the user button (blue SW) is pressed and held for 3 seconds or longer, the counter will reset to 0000. ALso, if the counter is currently auto‑incrementing, it should stop auto‑incrementing when the user button is held for 3 seconds or longer.

  • Explain and justify the approach you took to implement this functionality in your markdown file.