cancel
Showing results for 
Search instead for 
Did you mean: 

ADC with DMA cracks the system

YAkse
Associate III

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.

3 REPLIES 3
YAkse
Associate III

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.

Likely saturating system with interrupts for one word.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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