完整--基于DSP的FIR低通滤波器设计论文 - 图文(6)

2019-04-21 21:09

fSignal1=0.0; fSignal2=PI*0.1; fStepSignal1=2*PI/30; fStepSignal2=2*PI*1.4; while ( 1 ) { fInput=InputWave(); fIn[nIn]=fInput; nIn++; nIn%=256; fOutput=FIR(); fOut[nOut]=fOutput; nOut++;

/* break point */

if ( nOut>=256 )

{ nOut=0;

}

}

}

float InputWave() { for ( i=FIRNUMBER-1;i>0;i-- )

fXn[i]=fXn[i-1];

fXn[0]=sin((double)fSignal1)+cos((double)fSignal2)/6.0; fSignal1+=fStepSignal1;

if ( fSignal1>=f2PI ) fSignal1-=f2PI; fSignal2+=fStepSignal2;

if ( fSignal2>=f2PI ) fSignal2-=f2PI; return(fXn[0]);

}

float FIR() {

float fSum;

22

fSum=0;

for ( i=0;i

}

return(fSum);

}

程序2

#include \

void SDRAM_init( void ) {

ioport unsigned int *ebsr =(unsigned int *)0x6c00; ioport unsigned int *egcr =(unsigned int *)0x800; ioport unsigned int *emirst=(unsigned int *)0x801; //ioport unsigned int *emibe =(unsigned int *)0x802; ioport unsigned int *ce01 =(unsigned int *)0x803; //ioport unsigned int *ce02 =(unsigned int *)0x804; //ioport unsigned int *ce03 =(unsigned int *)0x805; ioport unsigned int *ce11 =(unsigned int *)0x806; //ioport unsigned int *ce12 =(unsigned int *)0x807; //ioport unsigned int *ce13 =(unsigned int *)0x808; ioport unsigned int *ce21 =(unsigned int *)0x809; //ioport unsigned int *ce22 =(unsigned int *)0x80A; //ioport unsigned int *ce23 =(unsigned int *)0x80B; ioport unsigned int *ce31 =(unsigned int *)0x80C; //ioport unsigned int *ce32 =(unsigned int *)0x80D; //ioport unsigned int *ce33 =(unsigned int *)0x80E; ioport unsigned int *sdc1 =(unsigned int *)0x80F; //ioport unsigned int *sdper =(unsigned int *)0x810; //ioport unsigned int *sdcnt =(unsigned int *)0x811; ioport unsigned int *init =(unsigned int *)0x812; ioport unsigned int *sdc2 =(unsigned int *)0x813; //*ebsr = 0x221;//0xa01

23

*ebsr = 0xa01; *egcr = 0x220; *egcr = 0X220; *ce01 = 0X3000; *ce11 = 0X1fff; *ce21 = 0x1fff; *ce31 = 0x1fff; *emirst = 0; *sdc1 = 0X5958; *sdc2 = 0X38F; *init = 0; } 程序3

#include\

void CLK_init() {

ioport unsigned int *clkmd; clkmd=(unsigned int *)0x1c00;

*clkmd =0x2033; // 0x2033;//0x2413;// 200MHz=0x2513 }

void SetDSPPLL(unsigned int uPLL) {

ioport unsigned int *clkmd; clkmd=(unsigned int *)0x1c00; *clkmd =uPLL; }

void TMCR_reset( void ) {

ioport unsigned int *TMCR_MGS3=(unsigned int *)0x07FE; ioport unsigned int *TMCR_MM =(unsigned int *)0x07FF; *TMCR_MGS3 =0x510;

24

*TMCR_MM =0x000; } 程序4

wst=0.88*pi; wp=0.4*pi;

deltaw=wst-wp; %过渡带宽△w的计算

N0=ceil(11*pi/deltaw); %按布莱克曼窗计算所需的滤波器长度

N=N0+mod(N0+1,2); %为了实现第一类偶对称滤波器,应确保其长度N为奇数 n=[0:1:N-1];

wc=(wst+wp)/2; %截止频率取为两边缘频率的平均值 hd=ideal(wc,N); %求理想脉冲响应 wdbla=(blackman(N))'; %求窗函数

h=hd.*wdbla; %设计的脉冲响应应为理想脉冲响应与窗函数乘积 [db,mag,pha,grd,w]=myfreqz(h,[1]); %对设计结果进行检验 dw=2*pi/2000; %频率分辨率 Rp=-(min(db(1:wp/dw+1))) %检验通带波动 As=-round(max(db(wst/dw+1:501))) %检验最小阻带衰减 figure(1) subplot(2,2,1); stem(n,wdbla);

title('布莱克曼窗') %绘制布莱克曼窗 axis([0 N-1 0 1.1]);ylabel('w(n)'); text(N+1,0,'n') subplot(2,2,2); stem(n,h);

title('实际脉冲响应') %绘制实际脉冲响应 axis([0 N-1 -0.4 0.5]); xlabel('n'); ylabel('h(n)') subplot(2,2,3);

plot(w/pi,db); %绘制幅度响应; title('幅度响应(单位:dB)'); grid;

axis([0 1 -150 10]);

xlabel('频率(单位: pi)'); ylabel('分贝数')

set(gca,'XTickMode','manual','XTick',[0,0.2,0.35,0.65,0.8,1]) set(gca,'YTickMode','manual','YTick',[-60,0]) subplot(2,2,4); plot(w,pha);

title('相位响应'); %绘制相频特性 axis([0 2 -4 4]);

xlabel('频率(单位:pi)');

25

ylabel('相位(Φ)')

程序5

function hd=ideal(wc,M); al=(M-1)/2; n=[0:(M-1)]; m=n-al+eps;

hd=sin(wc*m)./(pi*m);

程序5

function [db,mag,pha,grd,w]=myfreqz(b,a); N=1000;

[H,w]=freqz(b,a,N,'whole');

H=(H(1:1:501))';w=(w(1:1:501))'; mag=abs(H);

db=20*log10((mag+eps)/max(mag)); pha=angle(H);

grd=grpdelay(b,a,w);

26


完整--基于DSP的FIR低通滤波器设计论文 - 图文(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:35首用浙江省公路统一用表(JS)101-226

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: