real time FFT on c6713 DSK
CASTalk.com Forum Index CASTalk.com
Discussion of DSP, FPGA, storage and embedded system.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web castalk.com
real time FFT on c6713 DSK

 
Post new topic   Reply to topic    CASTalk.com Forum Index -> DSP
Author Message
olubern
Guest





Posted: Sun Dec 04, 2005 5:15 pm    Post subject: real time FFT on c6713 DSK Reply with quote

I'm trying to do a 2048 pt real FFT using fft6713.c as my reference code.
When I tested this code with a CD music, (fs changed to 44.1KHz) I realiz
some of the samples from the ADC were overwritten while the FFT is bein
done (Obviously I can't do the FFT process in one sample time)
Is there a way to store samples from the ADC and do the FFT prcoessin
simultaneouly on the C6713 DSK.
The main file is posted below. I'll appreciate all the help I can get o
this.
Thanks in advance,
Bernard.


void main()
{
// Codec data handle structure
DSK6713_AIC23_CodecHandle hCodec;

for (i = 0 ; i<PTS ; i++) // set up twiddle constants in w
{
w[i].real = cos(2*PI*i/2048.0); //Re component of twiddle constants
w[i].imag =-sin(2*PI*i/2048.0); //Im component of twiddle constants
}

/* Initialize the board support library, must be called first */
DSK6713_init();
/* Start the codec */
hCodec = DSK6713_AIC23_openCodec(0, &config);
// Set sampling frequency via the number before KHZ in the define.
// Choose from 8, 16, 24, 32, 44.1, 48, or 96 Khz.
DSK6713_AIC23_setFreq(hCodec, DSK6713_AIC23_FREQ_8KHZ);


// Infinite loop so that we can continue to process samples forever

while(1)
{
while (!DSK6713_AIC23_read(hCodec, &xL));
while (!DSK6713_AIC23_read(hCodec, &xR));

//Input left channel sample from ADC
iobuffer[buffercount++] = (float)((short) xL);
//Use the next line to noise test the filter
//input = 0.5*((short) rand_int()); //scale by 1/2
if (buffercount >= PTS) //if iobuffer full
{
buffercount = 0; //reinit buffercount
flag = 1; //set flag
}

// When iobuffer is full fft the data after copying into a
// the complex samples[].real. Note we set the imaginary part
// equal 0, i.e., samples[i].imag = 0.0. You can view the FFT
// result by opening a CCS graph window on the array x or length
// PTS. AT this time PTS is set to 2048, but can be changed.
if (flag == 1) //wait until iobuffer is full
{
flag = 0; //reset flag
for (i = 0 ; i < PTS ; i++) //swap buffers
{
samples[i].real=iobuffer[i]; //buffer with new data
iobuffer[i] = x[i]; //processed frame to iobuffer
}
for (i = 0 ; i < PTS ; i++)
samples[i].imag = 0.0; //imag components = 0

FFT(samples,PTS); //call function FFT.c

for (i = 0 ; i < PTS ; i++) //compute magnitude
{
x[i] = sqrt(samples[i].real*samples[i].real
+ samples[i].imag*samples[i].imag)/32;
}
x[0] = 32000.0; //negative spike
} //end of FFT frame process

// The input samples are written to the output as a loop through,
// but when the FFT is performed (once per frame) there is a
// large delay in writing samples to the output, and fact
// consecutive input samples are dropped, thus making the IO
// non real-time. With interrupt processing, instead of this
// polling scheme, this could be avoided.

// Write a 32 bit signal sample to the serial port.
// The writing ping-pongs between left and right channels.
while (!DSK6713_AIC23_write(hCodec, xL));
while (!DSK6713_AIC23_write(hCodec, xR));
}

/* Close the codec in theory, but unreachable with the above whil
loop*/
//DSK6713_AIC23_closeCodec(hCodec);
}
Back to top
Jerry Avins
Guest





Posted: Mon Dec 05, 2005 12:14 am    Post subject: Re: real time FFT on c6713 DSK Reply with quote

olubern wrote:
Quote:
I'm trying to do a 2048 pt real FFT using fft6713.c as my reference code.
When I tested this code with a CD music, (fs changed to 44.1KHz) I realize
some of the samples from the ADC were overwritten while the FFT is being
done (Obviously I can't do the FFT process in one sample time)
Is there a way to store samples from the ADC and do the FFT prcoessing
simultaneouly on the C6713 DSK.
The main file is posted below. I'll appreciate all the help I can get on
this.
Thanks in advance,
Bernard.

How about double buffering?

Jerry
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Back to top
Howard Long
Guest





Posted: Mon Dec 05, 2005 1:35 pm    Post subject: Re: real time FFT on c6713 DSK Reply with quote

"olubern" <w101boa@wright.edu> wrote in message
news:442dnfqvgYImaw_enZ2dnUVZ_sqdnZ2d@giganews.com...
Quote:
I'm trying to do a 2048 pt real FFT using fft6713.c as my reference code.
When I tested this code with a CD music, (fs changed to 44.1KHz) I realize
some of the samples from the ADC were overwritten while the FFT is being
done (Obviously I can't do the FFT process in one sample time)
Is there a way to store samples from the ADC and do the FFT prcoessing
simultaneouly on the C6713 DSK.
The main file is posted below. I'll appreciate all the help I can get on
this.

You can use an interrupt service routine on the MCBSP on Int11 to service
each ADC sample, storing them in a buffer. Once the buffer is full, the ISR
signals the main() process to say it's ready. Main() then processes the FFT.
One caveat: make sure that the buffer that's being processed in main() isn't
overwritten by the ISR. Either swap between two sets of buffers, or
immediately take a copy of the data in main() when it's been signalled.
Tachnically, double buffering would be the safest solution.

The problem with using an ISR, especially at higher sampling rates is that
the rate of interrupts is rather high.

As an alternative to a MCBSP ISR, the use of the EDMA module is preferred,
although it's a lot more complicated to achieve.

Rulph Chassaing's book "Digital Signal Processing and Applications with the
C6713 and C6416 DSK" carries the FastConvo example covering the interrupt
method.

You can modify the dsk_app DSK example to provide a similar result using the
EDMA module.

Regards, Howard
Back to top
Guest






Posted: Mon Dec 05, 2005 4:21 pm    Post subject: Re: real time FFT on c6713 DSK Reply with quote

i see that you are writing real fft. since my knowledge of ccs is low
and i have to write program that will calculate real fft in c6713 DSK
maybe you can place piece of code here that will do that for me.
Back to top
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> DSP All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




VoIP Electronics Powered by phpBB