Page 1 of 1
ICU driver and DMA ?
Posted: Wed Dec 28, 2016 3:41 pm
by omcdr
I have STM32F411 board. My input signal is at PA1 pin - TIM2_CH2. I want to run input capture feature and get samples to 128 width array with DMA in circular mode.
Is it possible to use ICU driver with DMA circular mode on STM32F4 platform ?
I have seen PWM-ICU example, but I don't know how to use it with DMA.
Re: ICU driver and DMA ?
Posted: Wed Dec 28, 2016 3:45 pm
by Giovanni
Hi,
It should be possible by configuring the DIER register in the ICUConfig structure.
See the STM32 Reference Manual for details.
Giovanni
Re: ICU driver and DMA ?
Posted: Wed Dec 28, 2016 6:45 pm
by omcdr
My ICUConfig looks like:
Code: Select all
static ICUConfig icucfg = {
ICU_INPUT_ACTIVE_HIGH,
10000,
NULL,
NULL,
NULL,
ICU_CHANNEL_2,
TIM_DIER_CC2DE | TIM_DIER_TDE
};
Whether it is the correct configuration ?
And next I have arrray and dmaStreamAllocate, how tu enable DMA in circular mode (peripheral-to-memory)?
Code: Select all
uint32_t samples[128];
if (dmaStreamAllocate(STM32_DMA2_STREAM6, 0, NULL, NULL))
chSysHalt("DMA already in use");
Re: ICU driver and DMA ?
Posted: Wed Dec 28, 2016 7:13 pm
by Giovanni
Hi,
You can find an example of circular DMA in the ADC or I2S drivers
Giovanni
Re: ICU driver and DMA ?
Posted: Sat Mar 04, 2017 12:37 pm
by alex31
Hello omcdr,
If you were able to achive ICU driver and DMA, it would be nice to post here a working snipset of your code, if it's possible for you.
It can help people not to reinvent wheel

Alexandre
Re: ICU driver and DMA ?
Posted: Sun Mar 05, 2017 10:33 pm
by omcdr
I don't have ICU with DMA.
Re: ICU driver and DMA ?
Posted: Sun Mar 04, 2018 11:45 am
by alex31
Hi,
Finally, i took time to read TIM and DMA section of RM090, and using dma helper functions, was able to capture both width and period with DMA.
tips : need to use burst mode, which involve from TIM side, TIMx_DCR and TIMx_DMAR, explanations in RM090 are quite clear.
Since i am a teacher, and i plan to add DMA to my lectures, i think that right now, DMA API is a bit harsh.
(the class will be centered on this exercise : decoding an ADSB mode-S 112 bits frame)
adsb mode s documentation What about making DMA a first class citizen, and giving it a API like the other peripheral, with structure configuration, and a start, stop, startTransfert API ?
If this has a chance to get in ChibiOS in the future, i can work on it to propose a draft.
Albeit for teaching purpose, a simpler API could permit to chibios users to easily use DMA for peripheral that are not yet managed.
Alexandre
Re: ICU driver and DMA ?
Posted: Sun Mar 04, 2018 11:55 am
by Giovanni
Hi,
Problem is that DMA is very different on different MCUs, it would be hard to make a portable driver when you have to set very specific options.
Giovanni