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

📄 128cfft.txt

📁 128点FFT滤波的程序
💻 TXT
字号:
//---------------------------------------------------//
//------调用FFT库的文件进行复数FFT计算--------------//
//--------------------------------------------------//


#include "DSP281x_Device.h" // DSP281x Headerfile Include File
#include "DSP281x_Examples.h" // DSP281x Examples Include File
#include "fft.h"
#include "math.h"


#define     N   128

#pragma DATA_SECTION(ipcb, "FFTipcb");
#pragma DATA_SECTION(mag, "FFTmag");
// Prototype statements for functions found within this file.
// Global variables used in this example:

CFFT32  fft=CFFT32_128P_DEFAULTS;

long ipcb[2 * N];
long mag[N];
//const long win[BUF_SIZE/2]=HANNING128;




main()
{
Uint16 i;

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP281x_SysCtrl.c file.
InitSysCtrl();
// For this example, set HSPCLK to SYSCLKOUT / 6 (25Mhz assuming 150Mhz SYSCLKOUT)
EALLOW;
SysCtrlRegs.HISPCP.all = 0x3; // HSPCLK = SYSCLKOUT/6
EDIS;

// Step 2. Initialize GPIO: 
// This example function is found in the DSP281x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
InitGpio(); // Skipped for this example 
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts 
DINT;
// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared. 
// This function is found in the DSP281x_PieCtrl.c file.
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
// Initialize the PIE vector table with pointers to the shell Interrupt 
// Service Routines (ISR). 
// This will populate the entire table, even if the interrupt
// is not used in this example. This is useful for debug purposes.
// The shell ISR routines are found in DSP281x_DefaultIsr.c.
// This function is found in DSP281x_PieVect.c.
InitPieVectTable();

// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file. 
// EALLOW; // This is needed to write to EALLOW protected register
// PieVectTable.ADCINT = &adc_isr;
// EDIS; // This is needed to disable write to EALLOW protected registers
// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP281x_InitPeripherals.c
// InitPeripherals(); // Not required for this example


PieCtrlRegs.PIEIER1.bit.INTx6 = 1;
IER |= M_INT1; // Enable CPU Interrupt 1
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM


for(i=0;i<N;i++)
{
 Voltage1[i]=(long)1000*sin((2*3.14159*i)/25);
ipcb[i]=10000*Voltage1[i];

}




//initialize FFT module
fft.ipcbptr=ipcb;        //FFT算法缓存区
fft.magptr=mag;         //存放幅度
fft.init(&fft);          //旋转因子初始化


GpioDataRegs.GPASET.all=0x0001;

CFFT32_brev2(ipcb,ipcb,N);  /* 倒位序计算 */


fft.izero(&fft);        /* 虚部为0 */
fft.calc(&fft);        //运行FFT
fft.mag(&fft);
GpioDataRegs.GPACLEAR.all=0x0001;

}

⌨️ 快捷键说明

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