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

📄 复件 (2) 2812 fft.c

📁 TMS320F2812芯片实现FFT的算法
💻 C
字号:
//利用汇编语言和TMS320F2812芯片实现FFT的算法,该算法对128点和256点很有效,使用过程中要考虑信号值不能太小.

 

#include "DSP28_Device.h"       /*DSP28xx Headerfile Include File*/
#include "DSP281x_Examples.h"     /* DSP28xx Examples Include File*/
#include "fft.h"
#include "math.h"

#define FFTN256 128
#define f 10
#define pi 3.1415926
#pragma DATA_SECTION(ipcb, "FFTipcb");

#pragma DATA_SECTION(mag, "FFTmag");/* Prototype statements for functions found within this file.
                                  Global variables used in this example*/
RFFT32 fft=RFFT32_128P_DEFAULTS;
long ipcb[FFTN256+2];                      /*in place computation buffer*/
long mag[FFTN256/2+1];                     /*magnitude buffer*/
const long win[FFTN256/2]=HANNING128;      /*window coefficent array*/
int m=0;
long n;
long p, q;
unsigned int mod[256];

main()
{
  Uint16 i;
  for(i=0;i<FFTN256;i++)
  {
   ipcb[i]= (long)(10000000*sin((2*pi*i)/12));
 
  }

   /*initialize FFT module */
   /* FFT 初始化 */
   fft.ipcbptr=ipcb;                      /* FFT 运算缓冲区数组首地址赋予ipcbptr指针*/                  /* FFT computation buffer pointer*/
   fft.magptr=ipcb;                       /*幅值平方数组首地址赋予magptr指针 */                         /*store back the mag.square in*/
   fft.winptr=(long *)win;                /* 窗数据数组首地址赋予winptr指针*/                           /* window coefficient array*/
   fft.init(&fft);                         /*copy twiddle factor*/

   RFFT32_brev(ipcb,ipcb,FFTN256);
   
   /* FFT 运算*/
   fft.win(&fft);                          /* 输入数据加窗*/               /*window the input data*/
   fft.calc(&fft);                         /* 虚部置零*/                   /*zero the imaginary part*/
   fft.split(&fft);                        /* FFT 计算*/                   /*compute the FFT*/
   fft.mag(&fft);                          /* 幅值平方运算 */              /*obtain the magnitude square*/
   m=0;
   for(i=0;i<256;i+=2)
   {
    p=ipcb[i];                 //在ipcb[512]数组中,偶数为实部,奇数为虚部及幅值的平方(放在mag[256])数组中
    q=ipcb[i+1];
    n=p*p+q*q;
    n=sqrt(n);
    mod[m]=n;
    m++;
   }
}

⌨️ 快捷键说明

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