ICU driver and DMA ?

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

omcdr
Posts: 89
Joined: Wed Aug 17, 2016 3:25 pm
Has thanked: 7 times
Been thanked: 7 times

ICU driver and DMA ?

Postby omcdr » Wed Dec 28, 2016 3:41 pm

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.

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: ICU driver and DMA ?

Postby Giovanni » Wed Dec 28, 2016 3:45 pm

Hi,

It should be possible by configuring the DIER register in the ICUConfig structure.

See the STM32 Reference Manual for details.

Giovanni

omcdr
Posts: 89
Joined: Wed Aug 17, 2016 3:25 pm
Has thanked: 7 times
Been thanked: 7 times

Re: ICU driver and DMA ?

Postby omcdr » Wed Dec 28, 2016 6:45 pm

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");

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: ICU driver and DMA ?

Postby Giovanni » Wed Dec 28, 2016 7:13 pm

Hi,

You can find an example of circular DMA in the ADC or I2S drivers

Giovanni

User avatar
alex31
Posts: 379
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 38 times
Been thanked: 62 times
Contact:

Re: ICU driver and DMA ?

Postby alex31 » Sat Mar 04, 2017 12:37 pm

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

omcdr
Posts: 89
Joined: Wed Aug 17, 2016 3:25 pm
Has thanked: 7 times
Been thanked: 7 times

Re: ICU driver and DMA ?

Postby omcdr » Sun Mar 05, 2017 10:33 pm

I don't have ICU with DMA.

User avatar
alex31
Posts: 379
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 38 times
Been thanked: 62 times
Contact:

Re: ICU driver and DMA ?

Postby alex31 » Sun Mar 04, 2018 11:45 am

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

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: ICU driver and DMA ?

Postby Giovanni » Sun Mar 04, 2018 11:55 am

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


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 26 guests