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

📄 myfir__nonbios.c

📁 DSP源码程序: FIR滤波器程序
💻 C
字号:
//刘鑫茂 AVIC613 2008.4.15
//测试FIR及CPUTIMER0,1,2
#include "DSP281x_Device.h"     // DSP281x Headerfile Include File
#include "DSP281x_Examples.h"   // DSP281x Examples Include File
#include "IQmathLib.h"
#include "filter.h"
#include <math.h>
#include <stdio.h>

#define FIR_ORDER 50
#pragma DATA_SECTION(lpf, "firfilt");
FIR16 lpf=FIR16_DEFAULTS;
#pragma DATA_SECTION(dbuffer,"firldb");
long dbuffer[(FIR_ORDER+2)/2];
const long coeff[(FIR_ORDER+2)/2]=FIR16_LPF50; 
int xn[100];
int	index,in,in1,input,output;
float yn[100];
float out;

// Prototype statements for functions found within this file.
interrupt void cpu_timer0_isr(void);
interrupt void cpu_timer1_isr(void);
interrupt void cpu_timer2_isr(void);
void main(void)
{

   InitSysCtrl();
   DINT;
   InitPieCtrl();
   IER = 0x0000;
   IFR = 0x0000;
   InitPieVectTable();
   EALLOW;  // This is needed to write to EALLOW protected registers
   GpioMuxRegs.GPFMUX.bit.SPISTEA_GPIOF3 = 0;
   GpioMuxRegs.GPFDIR.bit.GPIOF3 = 1;
   PieVectTable.TINT0 = &cpu_timer0_isr;
   PieVectTable.XINT13= &cpu_timer1_isr;
   PieVectTable.TINT2 = &cpu_timer2_isr;
   GpioMuxRegs.GPEMUX.bit.XNMI_XINT13_GPIOE2=1;
   XIntruptRegs.XNMICR.bit.ENABLE=0;
   XIntruptRegs.XNMICR.bit.SELECT=0;
   EDIS;    // This is needed to disable write to EALLOW protected registers
   InitCpuTimers();   // For this example, only initialize the Cpu Timers
   ConfigCpuTimer(&CpuTimer0, 100, 1000000);
   ConfigCpuTimer(&CpuTimer1, 100, 1000000);
   ConfigCpuTimer(&CpuTimer2, 100, 1000000);
   StartCpuTimer0();
   StartCpuTimer1();
   StartCpuTimer2();
   IER |= M_INT1;
   IER |= M_INT13;
   IER |= M_INT14;
   PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
   EINT;   // Enable Global interrupt INTM
   ERTM;   // Enable Global realtime interrupt DBGM
	for(index=0;index<100;index++)
	{
		xn[index]=(int)((sin(0.02454*500*index)*32768)+(0.8*sin(0.02454*8888*index)*32768)+(0.5*sin(0.02454*888*index)*32768)+(0.3*sin(0.02454*2500*index)*32768));

	}
	lpf.dbuffer_ptr=dbuffer;
	lpf.coeff_ptr=(long *)coeff;
	lpf.order=FIR_ORDER;
	lpf.init(&lpf);
	index=0;
	index=1;
	for(;;)
	{
		index=0;
		for(index=0;index<100;index++)
		{
			xn[index]=xn[index+1];
		}
		xn[99]=xn[0];
		for(index=0;index<100;index++)
		{
			input=xn[index];
			lpf.input=input;
			lpf.calc(&lpf);
			output=lpf.output;
			out=(float)output/32768;
			yn[index]=out;
		}
	}
} 


interrupt void cpu_timer0_isr(void)
{
   PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}

interrupt void cpu_timer1_isr(void)
{
   PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}

interrupt void cpu_timer2_isr(void)
{
   GpioDataRegs.GPFTOGGLE.bit.GPIOF3 = 1;	
   PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
//刘鑫茂 AVIC613 2008.4.15

⌨️ 快捷键说明

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