2017-01-15 12:34 PM
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
Solved! Go to Solution.
2017-01-26 02:59 AM
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.
2017-01-26 02:59 AM
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.
2017-04-07 08:29 AM
Hello
Barragan.Ernesto
,I reported this issue internally to our CubeMx team for further check and investigation.
Thank your for your contribution.
Regards
Imen
2017-08-25 03:37 AM
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