⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fftrd.c

📁 关于傅立叶变换的宝贵资料
💻 C
字号:
/* ==============================================================================

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 <stb.h>
#include <fft.h>

/* Create an instance of Signal generator module    */
SGENTI_1 sgen = SGENTI_1_DEFAULTS;

/* Create an instance of DATALOG Module             */
DLOG_4CH dlog=DLOG_4CH_DEFAULTS;      
    
/* Create an Instance of FFT module                 */
#define     TWO_N   512 
#pragma DATA_SECTION(ipcb, "FFTipcb");
#pragma DATA_SECTION(mag, "FFTmag");

RFFT32  fft=RFFT32_512P_DEFAULTS;     
long ipcb[TWO_N+2];
long mag[TWO_N/2+1];  

/* Define window Co-efficient Array  and place the
.constant section in ROM memory				*/
const long win[TWO_N/2]=HAMMING512;   

/* Create an instance of FFTRACQ module             */
RFFT32_ACQ  acq=FFTRACQ_DEFAULTS;     
    
int xn,yn;
void main()
{    

/* DATALOG module initialisation                    */        
       dlog.iptr1=&xn;
       dlog.iptr2=&yn;
       dlog.trig_value=0x800;
       dlog.size=0x400;         /* Can log 1024 Samples                      */
       dlog.init(&dlog);

/* Signal Generator module initialisation           */ 
       sgen.offset=0;
       sgen.gain=0x7fff;        /* gain=1 in Q15                              */
       sgen.freq=10000;         /* freq = (Required Freq/Max Freq)*2^15       */
                                /*      = (931/3051.7)*2^15 = 10000           */         
       sgen.step_max=10000;     /* Max Freq= (step_max * sampling freq)/65536 */
                                /* Max Freq = (10000*20k)/65536 = 3051.7      */

/* Initialize acquisition module                    */
        acq.buffptr=ipcb;
        acq.tempptr=ipcb;
        acq.size=TWO_N;
        acq.count=TWO_N;
        acq.acqflag=1;

/* Initialize FFT module                            */
        fft.ipcbptr=ipcb;
        fft.magptr=mag;  
        fft.winptr=(long *)win;
        fft.init(&fft);  

/*---------------------------------------------------------------------------
    Nothing running in the background at present           
----------------------------------------------------------------------------*/

        while(1) 
        {
            sgen.calc(&sgen);
            xn=sgen.out;
            yn=sgen.out;
            dlog.update(&dlog);

            acq.input=((unsigned long)xn)<<16;
            acq.update(&acq);   

            if (acq.acqflag==0)     // If the samples are acquired      
            {   
                RFFT32_brev(ipcb,ipcb,TWO_N);
                RFFT32_brev(ipcb,ipcb,TWO_N);  // Input samples in Real Part

                fft.win(&fft); 
                RFFT32_brev(ipcb,ipcb,TWO_N);
                RFFT32_brev(ipcb,ipcb,TWO_N);  // Input after windowing 
    
                fft.calc(&fft);
                fft.split(&fft);
                fft.mag(&fft); 
                acq.acqflag=1;      // Enable the next acquisition          
            }

        }       

} /* End: main() */

             


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -