cancel
Showing results for 
Search instead for 
Did you mean: 

ADC DMA Doesnt Read Properly [Need Help and Advice]

dios_kuri
Associate III

Hi, so previously on other post I've been getting trouble with Poll Conversion of ADC using STM32F4 Discovery Board. Therefore i decided to use DMA instead.

I made the program using STM32CUBEMX and Keil uVision to read 5 different channels. All data then transmitted via USART. 

The problem now is my array (uint16_t adcvalarr[5])  only got the 1st index filled with value. Shown below is the result of transmitted data from Watch window and printf debug window.  

Watch Window: 

watch1.JPG

Debug printf viewer (from left to right: iteration number, array[0], array[1], array[2], array[3], array[4])

dma array output.JPG

I have also tried using potentiometer to alter ADC values of each channel but none of it seems to change the value in the array either. Is my ADC fried up or is it just something wrong with my code?

My main.c code is too long so i'll try to put it in the comment instead

===================================================================================

Thanks in advance! Any kind of info/insight will help me greatly.

 

 

13 REPLIES 13

Yes, if the input is shorted to GND and you're still getting 800-900, there is definitely something wrong with the hardware. Probably a protection diode is busted, perhaps it saw an overvoltage event.

This is assuming no errors in your test setup.

If you feel a post has answered your question, please click "Accept as Solution".

Make

uint16_t adcvalarr[5]={0};

 global (i.e. outside of any function), and also volatile.

JW

I'm gonna accept that harsh possibility as a truth. Most likely thats what causes hardfault whenever i use the polling version..

On the contrary, I wouldn't expect that to cause a hard fault. The polling version and the DMA version are exercising the same internal pathways. Probably a different bug happening there. But polling for multiple channels in a sequence doesn't really work on the F4 series.

If you feel a post has answered your question, please click "Accept as Solution".