Skip to main content
DBern.7
Associate II
February 4, 2022
Question

STM32F103C8T6 ADC1 + DMA reading gets corrupted when starting ADC2 conversion.

  • February 4, 2022
  • 3 replies
  • 1046 views

Hi,

I'm almost new to the STM32 and have the following question:

I'm triggering multichannel ADC1 conversions using timer 1 and storing the readings in a buffer using the DMA. It works fine until I configure ADC2 (which doesn't support DMA) to be triggered by timer 2. The sole addition of HAL_ADC_Start(&hadc2); or HAL_ADC_Start_IT(&hadc2); at the beginning of the code causes corrupted readings from ADC1+DMA. What am I doing wrong? Is it possible to trigger other ADCs while using DMA with another channel?

Thanks in advance

This topic has been closed for replies.

3 replies

TDK
Super User
February 4, 2022

Yes it's possible. Could be overloading DMA, what is your sample rate? What does "corrupted" mean exactly?

"If you feel a post has answered your question, please click ""Accept as Solution""."
DBern.7
DBern.7Author
Associate II
February 4, 2022

Hi, TDK

Thank you for the answer, The readings go from:

0693W00000JObqmQAD.pngto

 0693W00000JObrLQAT.pngonly by adding HAL_ADC_Start(&hadc2);

the sample is triggered in the second event of a capture compare running at 20Khz, so I suppose the sample rate is 10Khz

Thanks in advance

DBern.7
DBern.7Author
Associate II
February 4, 2022

Hi, TDK

Thank you for the answer, The readings go from:

0693W00000JObm6QAD.png 

to 0693W00000JObkeQAD.pngonly by adding HAL_ADC_Start(&hadc2);

the sample is triggered in the second event of a capture compare running at 20Khz, so I suppose the sample rate is 10Khz

Thanks in advance

DBern.7
DBern.7Author
Associate II
February 4, 2022

Changing DMA to Half Word and, consequently, the buffer data type to 16 bits did the trick. Still don't know why Thanks!