Skip to main content
Mj.soleimani
Associate
July 15, 2020
Question

STM32F746 ADC multi channel with DMA problem!!!

  • July 15, 2020
  • 3 replies
  • 878 views

Hi

I tried to use ADC 2 Channel Scan Mode with DMA circular but it didn't work...and very strange point is when i init DAC with DMA , ADC works. |:

anybody knows why?

how i use ADC DMA without DAC initialize?

thanks for your help.

the ADC configurations :

 hadc1.Instance = ADC1;

 hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2;

 hadc1.Init.Resolution = ADC_RESOLUTION_8B;

 hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;

 hadc1.Init.ContinuousConvMode = DISABLE;

 hadc1.Init.DiscontinuousConvMode = ENABLE;

 hadc1.Init.NbrOfDiscConversion = 1;

 hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;

 hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T2_TRGO;

 hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;

 hadc1.Init.NbrOfConversion = 2;

 hadc1.Init.DMAContinuousRequests = ENABLE;

 hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;

sConfig.Channel = ADC_CHANNEL_0;

 sConfig.Rank = ADC_REGULAR_RANK_1;

 sConfig.SamplingTime = ADC_SAMPLETIME_15CYCLES;

 sConfig.Channel = ADC_CHANNEL_6;

 sConfig.Rank = ADC_REGULAR_RANK_2;

This topic has been closed for replies.

3 replies

waclawek.jan
Super User
July 15, 2020

Read out and compare the content of ADC and DMA (and TIM2) registers between the working and non-working cases.

JW

TDK
July 16, 2020

Obviously initializing the DAC is not required for the ADC DMA to function correctly. The answer must be simpler. Possibly a relevant DMA clock is initialized by the DAC initialization that is missed or incorrectly sequenced in the ADC initialization. The issue is not in the code you linked.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Mj.soleimani
Associate
July 16, 2020

Thank you for reply ,TDK.

the ADC,DAC and DMA initialized by CubeMx.

shouldn't i trust the cube??

TDK
July 16, 2020
If it’s not working, what do you think? Once cube generates code for you, it’s yours. You’re responsible for making sure it does what you want and debugging it when necessary.
You also give no details on what “didnt work�? means. The bug could easily be somewhere else.
"If you feel a post has answered your question, please click ""Accept as Solution""."