📄 main.c
字号:
#include "f2407_c.h"
#include "fft.h"
#include "math.h"
#define PI 3.1415926
#define TWON 128 /* Real FFT Length */
#pragma DATA_SECTION(ipcb, "FFTipcb");
#pragma DATA_SECTION(mag, "FFTmag");
#pragma DATA_SECTION(win, "FFTwin");
FFT128R fft=FFT128R_DEFAULTS;
int data_acq[TWON+2];
int ipcb[TWON+2]; /* In place computation buffer */
int mag[TWON]; /* Magnitude buffer */
int win[TWON/2]=HAMMING128; /* Window coefficient array */
/****************************** MAIN ROUTINE ***************************/
void main(void)
{
unsigned int i;
*WDCR = 0x00E8;
*SCSR1 = 0x00fd;
*SCSR2 = (*SCSR2 | 0x000B) & 0x000F;
WSGR = 0x01c0;
*MCRA = 0x0003; /* group A pins */
*MCRB = 0xFEDC; /* group B pins */
*MCRC = 0x0000; /* group C pins */
asm(" setc INTM");
*IMR = 0x0000; /* clear the IMR register */
*IFR = 0xffff; /* clear any pending core interrupts */
*WDKEY =0x5555;
*WDKEY =0xaaaa;
for(i=0;i<TWON;i++)
{
data_acq[i]=4096*sin((2*PI*i)/128.0)+2048*sin((12*PI*i)/128.0)+1024*sin((24*PI*i)/128.0);
}
fft.ipcbptr=ipcb; /* FFT computation buffer */
fft.magptr=mag; /* Store mag. square in separate buff */
/*fft.winptr=win; /* Window coefficient array */
fft.init1(); /* Copy TF for complex FFT */
fft.init2(); /* Copy TF for Split function */
/* Acquire samples in bit reversed order or
Bit-reverse the in-order data using bit-rev utility */
FFTR_brev(data_acq,ipcb,TWON/2);
/* FFT Computation */
/*fft.win(&fft);*/
fft.calc(&fft); /* Zero the imaginary part */
fft.split(&fft); /* Compute the FFT */
fft.mag(&fft); /* Obtain the magnitude square */
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -