Dshot ESC Protocol on STM32 using DMA with Arduino IDE

After much studying of Betaflight (Home · betaflight/betaflight Wiki · GitHub) code and drivers, I’ve finally managed to get DMA based Dshot digital ESC protocol up and running on an STM32F411RE (STM32F411RE - High-performance access line, Arm Cortex-M4 core with DSP and FPU, 512 Kbytes of Flash memory, 100 MHz CPU, ART Accelerator - STMicroelectronics). This was a long journey for me to learn enough about STM32s and DMA transfers to get it working.

The code was developed using Arduino 1.8.5 as an IDE, with this STM Arduino core GitHub - stm32duino/Arduino_Core_STM32: STM32 core support for Arduino. The IDE was used to generate .elf files suitable for hardware debugging. Development was on an ST NUCLEO-F411RE development board using Segger J-Link and Ozone debugger tools. STM32 dedicated forum and post here http://www.stm32duino.com/viewtopic.php?f=48&t=4726.

I searched for simple Dshot example code for some time, but no joy. I’ll post my minimum viable test code here in case others are searching for the same.

Dshot is the digital interface protocol for electronic speed controllers now commonly found on higher performance quadcopters and multi-rotor drones. What is DShot ESC Protocol - Oscar Liang. This test demo was set up for Dshot600 timing.

Test output of 4 channels (TIM3 CCR1 and CCR2, TIM4 CCR1 and CCR2) was decoded with a Saleae logic probe and this protocol analyzer Michael Corcoran / logic-dshot · GitLab

The test code loads 4 separate dma buffers to store the individual TIMx channel CCRn bit values. Transfers are enabled in a timed loop, and disabled in each DMA stream transfer complete interrupt. Here is the minimum sketch that generated the output lower down in this post:

STM32F411RE_DShot_DWT_RevE.zip (2.95 KB)