Skip to main content
YAkse
Associate III
July 17, 2019
Question

ADC with DMA cracks the system

  • July 17, 2019
  • 3 replies
  • 904 views

Hey, I just have a simple code, relevant parts are attached below

uint32_t dataADC = 0 ; // globally defined

HAL_ADC_Start_DMA(&hadc1, &dataADC, 1); // after cubemx automatic inits

and that is all; in the while(1) loop, there is only a delay and toggle command. But the processor got stuck in this way. When I comment out the HAL_ADC_Start_DMA(&hadc1, &dataADC, 1); part, it works as normally an LED blink.

But if I let the command HAL_ADC_Start_DMA(&hadc1, &dataADC, 1); active, then I can see the adc reading(potentiometer) changes in the live debug but nothing inside while(1) loop happens.

What could be the problem ?

Thanks.

 Edit : I have tried a simpler example, and I am sure that the problem results from DMA.

This topic has been closed for replies.

3 replies

YAkse
YAkseAuthor
Associate III
July 17, 2019

Hey, I figured out that sampling time was the problem. It was default to 3 cycles, when I make it bigger, it worked. But Wy? I still didnt get. Because as I know, DMA works apart from the MCU. If anyone knows, can you please reply? thanks.

Tesla DeLorean
Guru
July 17, 2019

Likely saturating system with interrupts for one word.​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
YAkse
YAkseAuthor
Associate III
July 17, 2019

Hey, thanks for the answer. By interrupt, do you mean the internal working of DMA? Because I was not using ADC on interrupt mode.