Digital Signal Processing Reference
In-Depth Information
samples[i].imag = 0.0;
//imag components = 0
FFT(samples,PTS); //call function FFT.c
for (i = 0 ; i < PTS ; i++) //compute magnitude
{
x1[i] = sqrt(samples[i].real*samples[i].real
+ samples[i].imag*samples[i].imag)/32;
}
x1[0] = 32000.0; //negative spike(with AD535)for ref
} //end of infinite loop
} //end of main
interrupt void c_int11() //ISR
{
output_sample((int)(iobuffer[buffercount])); //out from
iobuffer
iobuffer[buffercount++]=(float)(input_sample());//input
to iobuffer
if (buffercount >= PTS)
//if iobuffer full
{
buffercount = 0;
//reinit buffercount
flag = 1;
//set flag
}
}
//FFT.c C callable FFT function in C
#define PTS 256 //# of points for FFT
typedef struct {float real,imag;} COMPLEX;
extern COMPLEX w[PTS]; //twiddle constants stored in w
void FFT(COMPLEX *Y, int N) //input sample array, # of
points
{
COMPLEX temp1,temp2; //temporary storage variables
int i,j,k; //loop counter variables
int upper_leg, lower_leg; //index of upper/lower
butterfly leg
 
Search WWH ::




Custom Search