/***************************************************************** * psd_fixpt_c55x.c - C program computes FFT-based PSD using C55x * assembly routines from TI DSPLIB for CCS ****************************************************************** * System configuration: * * _____ ____ __________ __________ * | | | | | | | | * x(n)-->| Buf |-->| BR |-->| (1/N)*FFT|-->| |X(k)|^2 |--> P(k) * |_____| |____| |__________| |__________| * * whrer * x(n) is included in data file "in_int_asm.dat" * *****************************************************************/ /* C header files */ #include "math.h" #include "tms320.h" #include "dsplib.h" #include "in_int_asm.dat" // input data file #include "def_complex_fixpt.h" // complex.h header file #pragma DATA_SECTION(spectrum, "fft_out"); /* define variables and constants */ lcomplex ltemp; DATA spectrum[N/2+1]; void main() { unsigned int i; rfft(inp,N,SCALE); /* perform magnitude-square */ spectrum[0]= (int)(((long)inp[0]*(long)inp[0])>>15)+1; spectrum[N/2]= (int)(((long)inp[1]*(long)inp[1])>>15)+1; for (i=1; i>15); ltemp.im = (((long)inp[(2*i)+1]*(long)inp[(2*i)+1])>>15); spectrum[i] = (int)(ltemp.re+ltemp.im)+1; // scaling is perform in fft } return; }