f2812.fft.asm.c

来自「利用汇编语言和TMS320F2812芯片实现FFT的算法」· C语言 代码 · 共 55 行

C
55
字号


#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.ipcbptr=ipcb;                       /* FFT computation buffer pointer*/
   fft.magptr=ipcb;                       /*store back the mag.square in*/
   fft.winptr=(long *)win;                 /* window coefficient array*/
   fft.init(&fft);                         /*copy twiddle factor*/

   RFFT32_brev(ipcb,ipcb,FFTN256);
   fft.win(&fft);                          /*window the input data*/
   fft.calc(&fft);                         /*zero the imaginary part*/
   fft.split(&fft);                        /*compute the FFT*/
   fft.mag(&fft);                          /*obtain the magnitude square*/
   m=0;
   for(i=0;i<256;i+=2)
   {
    p=ipcb[i];
    q=ipcb[i+1];
    n=p*p+q*q;
    n=sqrt(n);
    mod[m]=n;
    m++;
   }
}

⌨️ 快捷键说明

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