fft128c.c
上传用户:xxthzd
上传日期:2013-07-18
资源大小:24k
文件大小:2k
- /* ==============================================================================
- System Name: Real FFT - Software Test Bench (STB)
- File Name: FFTRD.C
- Description: Primary System file for demonstrating the Real FFT module
- Originator: Advanced Embeeded Control (AEC) - Texas Instruments
- Target dependency: x28x
- Description:
- ============
- */
- #include "DSP281x_Device.h"
- #include "fft.h"
- #include "const.h"
- #define N_FFT 8
- /* Create an Instance of FFT module */
- #define N 128
- #pragma DATA_SECTION(ipcb, "FFTipcb");
- #pragma DATA_SECTION(mag, "FFTmag");
- CFFT32 fft=CFFT32_128P_DEFAULTS;
- long ipcb[N_FFT][2*N];
- long mag[N_FFT][N];
- /* Define window Co-efficient Array and place the
- .constant section in ROM memory */
- const long win[N/2]=HAMMING128;
- Uint16 fftflag=0; //FFT转换启动标志:0不启动;1:启动
- extern Uint16 SampleTable[N_SAMPLE+1][N_ANALOG];
- void fft_data()
- {
- Uint16 i,j;
- if (fftflag==0)
- {
- for (i=0;i<N_FFT;i++)
- for (j=0;j<N;j++)
- {
- ipcb[i][2*j]=((unsigned long)SampleTable[j][2*i])<<16;
- }
- fftflag=1;
- }
- }
- void fft_subroutine()
- {
- Uint16 i;
- if (fftflag==1) // If the samples are acquired
- {
- for (i=0;i<N_FFT;i++)
- {
- /* Initialize FFT module */
- fft.ipcbptr=&ipcb[i][0];
- fft.magptr=&mag[i][0];
- fft.winptr=(long *)win;
- fft.init(&fft);
- {
- CFFT32_brev2(&ipcb[i][0],&ipcb[i][0],N);
- // CFFT32_brev2(&ipcb[i][0],&ipcb[i][0],N); // Input samples in Real Part
- /* fft.win(&fft);
- CFFT32_brev2(ipcb,ipcb,N);
- CFFT32_brev2(ipcb,ipcb,N); // Input after windowing
- */
- fft.izero(&fft);
- fft.calc(&fft);
- fft.mag(&fft);
- }
- }
- fftflag=0; // Enable the next acquisition
- GpioDataRegs.GPATOGGLE.bit.GPIOA15=1;
- }
- }