#include #include "math.h" #include "IQmathLib.h" #define PI 3.1415926536 #define FFT_N 256 #define GLOBLA_IQ 15 volatile float res; struct compx {float real,imag;}; //定义一个复数结构 struct compx s[FFT_N]; //FFT输入和输出 /******************************************************************* 函数原型:struct compx EE(struct compx b1,struct compx b2) 函数功能:对两个复数进行乘法运算 *******************************************************************/ float MM(float m,float n) { _iq qA,qB,qC; qA = _IQ(m); qB = _IQ (n) ; qC = _IQmpy(qA,qB); res=_IQtoF(qC); return(res); } struct compx EE(struct compx a,struct compx b) { struct compx c; c.real = MM(a.real,b.real) - MM(a.imag,b.imag); c.imag = MM(a.real,b.imag) + MM(a.imag,b.real); return(c); } void delay(int count) { int i; for(i = 0; i < count; i++) { asm("nop"); } } /************************************************************ 函数:void Reverse(struct compx *xin) 函数功能;地址变换 输入参数:*xin复数结构体组的首地址指针,struct型 ************************************************************/ void Reverse(struct compx *xin) //变换顺序好用 { int nv2,nm1,i,k,j=0; struct compx t; nv2=FFT_N/2; //变址运算,即把自然顺序变成倒位序 nm1=FFT_N-1; for(i=0;i