Embedded C firmware project for the STM32 Nucleo-F446RE developed using STM32CubeIDE.
This project demonstrates interrupt-driven button input, short-press vs long-press detection, and a finite state machine controlling multiple LED modes. The firmware also includes UART debug output to monitor system state transitions.
-
Short press cycles LED modes:
- Solid ON
- Quick flash
- SOS pattern
-
Long press turns LED OFF from any mode
-
Uses EXTI interrupts instead of polling
-
Implements software debouncing
-
Detects button press and release using rising and falling edge interrupts
-
Uses interruptible timing so flashing and SOS patterns stop immediately when the button is pressed
-
UART debug output via USART2 reports LED mode transitions
- STM32 Nucleo-F446RE
- Breadboard
- Pushbutton
- LED
- Current-limiting resistor
- Jumper wires
Button ───> PA8 (EXTI interrupt input)
LED ──────> PB5 (GPIO output)
UART ─────> USART2 → ST-LINK Virtual COM Port → PC Terminal
| Pin | Function |
|---|---|
| PA8 | Button input |
| PB5 | LED output |
Button input
PA8 → GPIO_MODE_IT_RISING_FALLING
PA8 → GPIO_PULLDOWN
LED output
PB5 → GPIO_MODE_OUTPUT_PP
Short press cycles through LED modes:
OFF → ON → FLASH → SOS → ON
Long press from any mode turns the LED off:
(any mode) → OFF
LED remains continuously on.
LED remains mostly off with a brief flash.
OFF 1000 ms
ON 100 ms
Standard Morse code SOS pattern:
S = short short short
O = long long long
S = short short short
The firmware provides UART debug messages via USART2 to report LED mode transitions.
Example terminal output:
MODE: ON
MODE: FLASH
MODE: SOS
MODE: OFF
This project demonstrates several important embedded firmware concepts:
- Embedded C programming
- STM32 HAL usage
- GPIO configuration
- External interrupt handling (EXTI)
- Button debouncing
- Short-press vs long-press detection
- Finite state machines
- Timing using
HAL_GetTick() - Interrupt-safe shared variables (
volatile) - Interruptible delay patterns
- UART debug logging
- STM32CubeIDE
- STM32 HAL Drivers
- ARM GCC Toolchain
Core/
Drivers/
STM32F446RETX_FLASH.ld
STM32F446RETX_RAM.ld
Interrupt1.ioc
README.md
.gitignore
The .ioc file allows the project to be reopened and modified using STM32CubeMX inside STM32CubeIDE.
This project was created as a learning exercise to explore real embedded firmware design patterns beyond simple LED blinking, including:
- interrupt-driven input handling
- state machine architecture
- responsive firmware behavior
- serial debugging
Michael Berry
