This project implements a Crossfire (CRSF) protocol receiver on an STM32F4 microcontroller using STM32CubeIDE. The receiver reads RC commands over UART and controls 4 PWM-based servos:
- Throttle
- Rudder
- Elevator
- Aileron
It also includes a failsafe mechanism to hold the last known valid RC signal in case of connection loss.
- β CRSF protocol parsing (OpenTX/EdgeTX compatible)
- β Maps 4 CRSF channels to servo PWM outputs
- β Uses TIM2 (CH2 & CH3) and TIM3 (CH1 & CH2) for servo control
- β Servo output in microseconds (1000β2000 Β΅s range)
- β Failsafe: holds last valid RC values after signal timeout
- β DMA-enabled UART reception for CRSF input
- β Built on STM32CubeIDE with HAL
- MCU: STM32F411 (or compatible STM32F4)
- UART: UART1 @ 420000 baud (CRSF standard)
- PWM Timers:
- TIM2 Channel 2 β Throttle
- TIM2 Channel 3 β Rudder
- TIM3 Channel 1 β Elevator
- TIM3 Channel 2 β Aileron
- Clone this repository and open it with STM32CubeIDE.
- Connect your STM32F4 via ST-Link or compatible programmer.
- Build and flash the firmware using the IDE (
Ctrl+BthenF8).
- Prescaler:
99 - Counter Period:
19999
CRSF packets are received over UART1, DMA-enabled, with idle-line detection for packet framing.
If no valid CRSF packet is received for a defined timeout (CRSF_PACKET_TIMEOUT_MS, default 100 ms), the system:
- Sets
failsafeActive = true - Maintains servo positions at their last valid state
- Resumes normal operation upon next valid packet
main.cβ Initialization, loop, CRSF handlingcrsf_serial.c/hβ CRSF protocol parserservo_control.c/hβ PWM output controltim.cβ TIM2 & TIM3 setup (auto-generated by STM32CubeMX)
| Channel Index | Function |
|---|---|
| 0 | Throttle |
| 1 | Rudder |
| 2 | Elevator |
| 3 | Aileron |
MIT License
Issues and pull requests welcome! Feel free to fork and modify for your own aircraft or drone project.