/***************************************************************** * psd_fixpt_c54x.c - C program computes FFT-based PSD using C54x * 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; // asm(" STM #0, SWWSR"); /* performs bit reversal, followed by FFT */ cbrev(inp,inp,N/2); // arrange X[] in bit-reverse order rfft(inp,N,1); // perform FFT with scaling of 0.5 in each stage /* 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; }