cancel
Showing results for 
Search instead for 
Did you mean: 

Problem of ADC with DMA

florianzebidi9
Associate
Posted on January 28, 2016 at 15:05

Hello,

I have a STM32F429I Discovery and I want to sample a signal from a hydrophone of 60-90 KHz before performing an FFT.

I work on Linux with GCC-ARM without EDI. (

http://manblaireau.net/Test/STM32F4_Builder_TEST.zip

)

So here's my problem: I use a code found on the forum to use three ADC with DMA and the value that is returned to me trough a software serial connection are inconsistent, see yourself:

My samples :

http://manblaireau.net/Test/sinus10_100.png

http://manblaireau.net/Test/sinus1000_10000.png

http://manblaireau.net/Test/sinus100000_ttl100000.png

And my code :

http://manblaireau.net/Test/main.c

I use a function generator directly in input of the ADC and my osciloscope confirms that it works.

Have an idea ? Thank you in advance and good day.

#stm3229i-discovery-adc-dma
2 REPLIES 2
Posted on January 28, 2016 at 16:16

Your buffer holds 3 samples, it strains credulity that you can read these values and output them at the rate you are suggesting. You need a bigger buffer, the ADC needs to be in continuous mode, and you want to have the DMA ping-pong between two halves of the buffer (HT/TC) so it's not overwriting data as you are working with it.

Doesn't look to be any triggering going on, and the output of data is totally asynchronous.

You need to think about the linear flow of data and time here, otherwise the data points you have are going to have no relationship to that.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
florianzebidi9
Associate
Posted on January 28, 2016 at 17:31

Hey ! Thanks for your response ! Very helpfull !

I had noticed that

my signal

appeared

asynchronous

but I thought

the

TIM2_Configuration

function

was used to

set the frequency

of

sampling

.

I

'll dig

the case.

So

I send the

first part of my

table

and then

the second

to avoid

overlap

acquisitions

?

With

this kind of

approach

:

(?)


void
DMA2_Stream0_IRQHandler(
void
) {

/* Test on DMA Stream Half Transfer interrupt */

if
(DMA_GetITStatus(DMA2_Stream0, DMA_IT_HTIF0)) {

/* Clear DMA Stream Half Transfer interrupt pending bit */

DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_HTIF0);


// save the first part of buffer here


}


/* Test on DMA Stream Transfer Complete interrupt */

if
(DMA_GetITStatus(DMA2_Stream0, DMA_IT_TCIF0)) {

/* Clear DMA Stream Transfer Complete interrupt pending bit */

DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_TCIF0);


// save the second part of buffer here


}

}

But then,

the

transmission

data

buffer

will not

interfere with the

sampling

?

I will

make

future

tests,

in any case

what you say

makes sense.

Thank you.