cancel
Showing results for 
Search instead for 
Did you mean: 

How to read 4 fast pulses

P S
Associate II
Posted on March 16, 2018 at 16:55

Hi All,

I am just getting started with stm32. I am using a stm32f031 mcu and am trying to read an input signal from a flight controller. The protocol used puts out a series of 4 pulses that vary from 1us to 2.6us in width with a 1us in between ( proshot protocol). I have used input capture with a timer for slower speed pulses but I have no luck with reading such short pulse durations. I am looking for clues as to how to read this? It seems input capture with interrupts is just too slow? Is DMA the solution here? can DMA read the 4 pulses one after another like this and store in an array? I am really new at this and I have spent a lot of time trying things than find out it could never work so this time I am asking first. Thanks for your help!

10 REPLIES 10
Posted on March 21, 2018 at 20:40

I am sorry, but i am not familiar with HAL. You don't need DMA transfer from channel 2, because it contains information about time between pulses (not about their lengths). You write that example 'doesn't work' ... i have absolutely no idea what could mean

 

follow these few steps:

1. check if timer resets with rising edge, if not, you have wrong configuration of TI2FP2 or slave controller

2. if timer is reset with rising edge of your pulse, you have to check if falling edge is captured in channel 1 ... it simple start program, insert pulses, stop program and check flag CC1IF (Compare/Capture Interrupt Flag). If is set, there was an capture event, look into TIM_CCR1 register and there should be timestamp of falling edge. If there is zero, probably you have set up wrong edge for channel 1 ...

3. if steps 1 and 2 works, there will be problem with DMA request configuration (check bit TIMx_CR2->CCDS and register TIMX->DIER) - Timers have complex DMA handling (burts and so on), thus tehere is room for mistakes...