DSPRelated.com
Forums

FFT 56807

Started by Marius Goosen September 6, 2007
Hi,

I am really new at programming a DSP, and a simple task is starting to cause
me some trouble.

I'm using the Motorola 56807 EVM with Cosewarrior and PE. I want to
calculate a simple FFT and transmit the data serially to the PC.

The problem is that as soon as I call the FFT function nothing happens?

I tested my ADC to serial connection and it worked fine but it stops working
when I implement the FFT.

I am using the FFT code as is in the help file:
#include "DFR1.h"

#include "MEM1.h"

#include "MFR1.h"
Frac16 pX[128];

dfr16_tRFFTStruct *pRFFT;

dfr16_sInplaceCRFFT *pZ;

UInt16 options = FFT_DEFAULT_OPTIONS;
pRFFT = dfr16RFFTCreate (8, options); /* N = 128 point RFFT */

res = dfr16RFFT (pRFFT, pX, pZ); /*Do the FFT*/

It seems to get stuck at the last line of code. If I comment it out
everything works fine but as soon as I include it the rest does not work

PLEASE HELP.

What am I doing wrong?
void calcAmplitude(short * values, volatile word * amp)
{
//find fft plot
static int cnt1;
static long ampReal = 0;
static long ampImag = 0;
static long ampTemp = 0;
static CFrac16 outFFTTable [FFT_SAMPLES/2+1];
static int j;

//perform fft and save values on the output table
DFR1_dfr16RFFT(fftPointer,&values[0], (dfr16_sInplaceCRFFT *)&outFFTTable[0] );

//take the first value from fft
ampReal = outFFTTable[1].real;
ampImag = outFFTTable[1].imag;
ampTemp = (ampReal*ampReal + ampImag*ampImag);

}
fftPointer = DFR1_dfr16RFFTCreate(FFT_SAMPLES, FFT_SCALE_RESULTS_BY_N|
FFT_INPUT_IS_BITREVERSED);

static CFrac16 outFFTTable [FFT_SAMPLES/2+1];

//perform fft and save values on the output table
DFR1_dfr16RFFT(fftPointer,&values[0], (dfr16_sInplaceCRFFT *)&outFFTTable[0] );
Hi,
>
>I am really new at programming a DSP, and a simple task is starting to cause
>me some trouble.
>
>I'm using the Motorola 56807 EVM with Cosewarrior and PE. I want to
>calculate a simple FFT and transmit the data serially to the PC.
>
>The problem is that as soon as I call the FFT function nothing happens?
>
>I tested my ADC to serial connection and it worked fine but it stops working
>when I implement the FFT.
>
>I am using the FFT code as is in the help file:
>#include "DFR1.h"
>
>#include "MEM1.h"
>
>#include "MFR1.h"
>Frac16 pX[128];
>
>dfr16_tRFFTStruct *pRFFT;
>
>dfr16_sInplaceCRFFT *pZ;
>
>UInt16 options = FFT_DEFAULT_OPTIONS;
> pRFFT = dfr16RFFTCreate (8, options); /* N = 128 point RFFT */
>
> res = dfr16RFFT (pRFFT, pX, pZ); /*Do the FFT*/
>
>It seems to get stuck at the last line of code. If I comment it out
>everything works fine but as soon as I include it the rest does not work
>
>PLEASE HELP.
>
>What am I doing wrong?
Hi

Sorry for the previous post, I accidentally pressed "Send Message"...Below there is a code that works perfectly for me. FFT_SAMPLES should be 8, 16, 32, etc. See: CodeWarrior help. Good luck!

dfr16_tRFFTStruct* fftPointer; //pointer to fft struct
fftPointer = DFR1_dfr16RFFTCreate(FFT_SAMPLES, FFT_SCALE_RESULTS_BY_N|FFT_INPUT_IS_BITREVERSED);//initialize fftPointer, for example in main...

//this is my function for calculating amplitude of sin signal
void calcAmplitude(short * values, volatile word * amp)
{
static int cnt1;
static long ampReal = 0;
static long ampImag = 0;
static long ampTemp = 0;
static CFrac16 outFFTTable [FFT_SAMPLES/2+1];

//perform fft and save values on the output table
DFR1_dfr16RFFT(fftPointer,&values[0], (dfr16_sInplaceCRFFT *)&outFFTTable[0] );

//take the first value from fft. I do it, because I know, that for me the first value is the one I'm intersted in (I allways obtain single sine wave, 0-2pi).

ampReal = outFFTTable[1].real;
ampImag = outFFTTable[1].imag;
ampTemp = (ampReal*ampReal + ampImag*ampImag);

}
Hi,
>
>I am really new at programming a DSP, and a simple task is starting to cause
>me some trouble.
>
>I'm using the Motorola 56807 EVM with Cosewarrior and PE. I want to
>calculate a simple FFT and transmit the data serially to the PC.
>
>The problem is that as soon as I call the FFT function nothing happens?
>
>I tested my ADC to serial connection and it worked fine but it stops working
>when I implement the FFT.
>
>I am using the FFT code as is in the help file:
>#include "DFR1.h"
>
>#include "MEM1.h"
>
>#include "MFR1.h"
>Frac16 pX[128];
>
>dfr16_tRFFTStruct *pRFFT;
>
>dfr16_sInplaceCRFFT *pZ;
>
>UInt16 options = FFT_DEFAULT_OPTIONS;
> pRFFT = dfr16RFFTCreate (8, options); /* N = 128 point RFFT */
>
> res = dfr16RFFT (pRFFT, pX, pZ); /*Do the FFT*/
>
>It seems to get stuck at the last line of code. If I comment it out
>everything works fine but as soon as I include it the rest does not work
>
>PLEASE HELP.
>
>What am I doing wrong?