cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with ADC and dma

Ernesto B
Associate II

Posted on January 15, 2017 at 21:34

 

 

The original post was too long to process during our migration. Please click on the attachment to read the original post.

https://community.st.com/s/question/0D50X00009XkdduSAB/triggering-adc-in-dual-mode-with-dma-problems

1 ACCEPTED SOLUTION

Accepted Solutions
Ernesto B
Associate II
Posted on January 26, 2017 at 11:59

At the end it seems the problem was this one:

https://community.st.com/0D50X00009XkdfSSAR

Having a look at the code generated by STM32CubeMX, where it says:

hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;�?�?�?�?

Is wrong, it should be:

hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;�?�?�?�?

So STM32CubeMX is not generating the correct initialization code for the chosen options.

Cheers.

View solution in original post

3 REPLIES 3
Ernesto B
Associate II
Posted on January 26, 2017 at 11:59

At the end it seems the problem was this one:

https://community.st.com/0D50X00009XkdfSSAR

Having a look at the code generated by STM32CubeMX, where it says:

hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;�?�?�?�?

Is wrong, it should be:

hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;�?�?�?�?

So STM32CubeMX is not generating the correct initialization code for the chosen options.

Cheers.

Imen.D
ST Employee
Posted on April 07, 2017 at 17:29

Hello

Barragan.Ernesto

,

I reported this issue internally to our CubeMx team for further check and investigation.

Thank your for your contribution.

Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on August 25, 2017 at 12:37

Hello

Barragan.Ernesto

,

I have tried to reproduce your configuration with CubeMX 4.

HoweverI'm unable to get the same generated code as you for the Peripheral DMA init.

If IactivateUse Fifo (enable FIFOMode), then I obtain:

hdma_adc1.Instance = DMA2_Stream0;

hdma_adc1.Init.Channel = DMA_CHANNEL_0;

hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY;

hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE;

hdma_adc1.Init.MemInc = DMA_MINC_ENABLE;

hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;

hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;

hdma_adc1.Init.Mode = DMA_NORMAL;

hdma_adc1.Init.Priority = DMA_PRIORITY_VERY_HIGH;

hdma_adc1.Init.FIFOMode = DMA_FIFOMODE_ENABLE;

hdma_adc1.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_HALFFULL;

hdma_adc1.Init.MemBurst = DMA_MBURST_SINGLE;

hdma_adc1.Init.PeriphBurst = DMA_PBURST_SINGLE;

But if I deactivate Use Fifo (disable FIFOMode), then I get:

hdma_adc1.Instance = DMA2_Stream0;

hdma_adc1.Init.Channel = DMA_CHANNEL_0;

hdma_adc1.Init.Direction = DMA_PERIPH_TO_MEMORY;

hdma_adc1.Init.PeriphInc = DMA_PINC_DISABLE;

hdma_adc1.Init.MemInc = DMA_MINC_ENABLE;

hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;

hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;

hdma_adc1.Init.Mode = DMA_NORMAL;

hdma_adc1.Init.Priority = DMA_PRIORITY_VERY_HIGH;

hdma_adc1.Init.FIFOMode = DMA_FIFOMODE_DISABLE;

You say that your problem is resolved when you change the source transfer width.

hdma_adc1

.

Init

.

PeriphDataAlignment

=

DMA_PDATAALIGN_WORD

;

If -as your code suggests - the Fifo is disabled (direct mode) then data packing/unpacking is not possible and the source and destination transfer data widths are the same and defined by PeriphDataAlignment (PSIZE). This means that although your 'corrected' source code may read:

hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;

hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;

the hardware implementationwill beequivalent to:

hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;

hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;

Can you please confirm whether the Fifo mode is enabled or disabled in you code?

Many thanks,

Angus