资源简介
FIR低通滤波器,主程序是c语言,汇编是辅助。完全的程序,可完全运行,注意是ccs软件!
代码片段和文件信息
/*********************************************************************************
The programme of the FIR filter.
Using INT2 to get the input signal.
Array x is the input signal from A/D the length is 256 32-bit floating point.
Array y is the signal out of filter the length is 256 32-bit floating point.
Array h is the coefficient of the FIR filter the length is 51 51 order filter.
**********************************************************************************/
#pragma CODE_SECTION(vect“vect“)
#include “stdio.h“
#include “math.h“
#define pi 3.1415927
#define IMR *(pmem+0x0000)
#define IFR *(pmem+0x0001)
#define PMST *(pmem+0x001D)
#define SWCR *(pmem+0x002B)
#define SWWSR *(pmem+0x0028)
#define AL *(pmem+0x0008)
#define CLKMD 0x0058 /* clock mode reg*/
#define Len 256
#define FLen 51
double npassh[FLen] x[Len] y[Len] xmid[FLen];
void firdes (double npass);
unsigned int *pmem=0;
ioport unsigned char port8002;
int in_x[Len];
int m = 0;
int intnum = 0;
double xmean=0;
int i=0;
int flag = 0;
double fsfstoprrm;
int ijpk=0;
void cpu_init()
{
*(unsigned int*)CLKMD=0x0; //switch to DIV mode clkout= 1/2 clkin
while(((*(unsigned int*)CLKMD)&01)!=0);
*(unsigned int*)CLKMD=0x77ff; //switch to PLL X 10 mode
PMST=0x3FA0;
SWWSR=0x7fff;
SWCR=0x0000;
IMR=0;
IFR=IFR;
}
interrupt void int2()
{
in_x[m] = port8002;
in_x[m] &= 0x00FF;
m++;
intnum = m;
if (intnum == Len)
{
intnum = 0;
xmean = 0.0;
for (i=0; i {
xmean = in_x[i] + xmean;
}
xmean = 1.0*xmean/Len;
for (i=0; i {
x[i] = (double)(in_x[i] - xmean);
}
for (i=0; i {
for (p=0; p {
xmid[FLen-p-1] = xmid[FLen-p-2];
}
xmid[0] = x[i];
r = 0;
rm= 0;
for (j=0; j {
r = xmid[j] * h[j];
rm = rm + r;
}
y[i] = rm;
}
m=0;
flag = 1;
}
}
void firdes(double npass)
{
int t;
for (t=0; t {
h[t] = sin((t-(FLen-1)/2.0)*npass*pi)/(pi*(t-(FLen-1)/2.0));
}
if (t == ((FLen-1)/2)) h[t]=npass;
}
void set_int()
{
asm(“ ssbx intm“);
IMR=IMR|0x0004;
asm(“ rsbx intm“);
}
void main(void)
{
cpu_init();
fs = 250000;
fstop = 20000;
npass = fstop/fs;
for (i=0; i {
xmid[i]=0;
}
firdes(npass);
set_int();
for(;;)
{
if (flag == 1)
{
flag = 0; /* set breakpoint here */
}
}
}
void vect()
{
asm(“ .ref _c_int00“); /*pseudoinstruction*/
asm(“ .ref _int2“);
asm(“ b _c_int00“); /* reset */
asm(“ nop“);
asm(“ nop“);
asm(“ rete“);
asm(“ nop“);
asm(“ nop“);
asm(“ nop“);
asm(“ rete“);
asm(“ nop“);
asm(“ nop“);
asm(“ nop“);
asm(“ rete“);
asm(“ n
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 529 2005-07-18 08:36 exp02_cpu2\Exp-FIR-AD\cc_build_Debug.log
文件 5259 2005-07-18 08:36 exp02_cpu2\Exp-FIR-AD\Debug\Exp-FIR-AD.map
文件 6911 2005-07-18 08:36 exp02_cpu2\Exp-FIR-AD\Debug\Exp-FIR-AD.obj
文件 9377 2005-07-18 08:36 exp02_cpu2\Exp-FIR-AD\Debug\Exp-FIR-AD.out
文件 363 2005-07-18 08:36 exp02_cpu2\Exp-FIR-AD\Debug.lkf
文件 363 2005-07-18 08:36 exp02_cpu2\Exp-FIR-AD\Debug.lkv
文件 1407 2005-07-18 08:37 exp02_cpu2\Exp-FIR-AD\Exp-FIR-AD.paf
文件 933 2005-07-18 08:37 exp02_cpu2\Exp-FIR-AD\Exp-FIR-AD.pjt
文件 5164 2005-07-18 08:36 exp02_cpu2\Exp-FIR-AD.c
文件 401 2004-03-03 09:29 exp02_cpu2\Exp-FIR-AD.cmd
文件 2744 2002-07-29 22:38 exp02_cpu2\math.h
文件 8397 2002-01-25 10:42 exp02_cpu2\MMRegs.h
文件 154882 1999-08-24 10:51 exp02_cpu2\RTS.LIB
文件 114 2001-10-06 20:15 exp02_cpu2\TYPEDEF.H
目录 0 2009-05-13 18:32 exp02_cpu2\Exp-FIR-AD\Debug
目录 0 2009-05-13 18:32 exp02_cpu2\Exp-FIR-AD
目录 0 2009-05-13 18:32 exp02_cpu2
----------- --------- ---------- ----- ----
196844 17
- 上一篇:LSI RAID配置手册(图文)
- 下一篇:新概念英语全四册电子版
评论
共有 条评论