This project demonstrates Input Capture mode on the STM32F446RE microcontroller using TIM2 Channel 1.
It measures the timer value when a rising edge occurs on the input pin.
- MCU: STM32F446RE (Nucleo Board)
- Input Pin: PA0 (TIM2_CH1)
- Clock Source: HSI (16 MHz)
- Prescaler: 15999 → Timer tick = 1 ms
- Mode: Input Capture (Rising Edge)
- Starts Timer 2 in Input Capture interrupt mode.
- Captures the counter value at each rising edge.
- Stores live counter in variable
counter. - Captured value from interrupt stored in
capture.
main.c→ Peripheral initialization and main loop.stm32f4xx_it.c→ Interrupt handler for TIM2 capture.main.h→ Function prototypes and includes.
- STM32CubeIDE
- STM32CubeMX
- HAL Drivers
- C Language (C99)
- Open project in STM32CubeIDE.
- Connect Nucleo-F446RE via USB.
- Build and flash.
- Monitor capture values via debugger or serial output.