dsp程序.docx_第1页
dsp程序.docx_第2页
dsp程序.docx_第3页
dsp程序.docx_第4页
dsp程序.docx_第5页
已阅读5页,还剩1页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

加法 .title myadd.asm .mmregsSTACK .usect STACK,10h .bss a,4 .bss x,4 .bss y,1 .def start .datatable .word 1,2,3,4 .word 8,6,4,2 .textstart STM #0,SWWSR STM #STACK+10H,SP STM #a,AR1 RPT #7 MVPD table,*AR1+ CALL SUM B endSUM STM #a,AR3 STM #x,AR4 RPTZ A,#3 MAC *AR3+,*AR4+,A STL A,y RETend .endFIR滤波器 .mmregsCOFF_FIR_START .sect coff_fir ; filter coefficients.word 6Fh.word 0F3h.word 269h.word 50Dh.word 8A9h.word 0C99h.word 0FF8h.word 11EBh.word 11EBh.word 0FF8h.word 0C99h.word 8A9h.word 50Dh .word 269h.word 0F3h .word 6FhCOFF_FIR_ENDK_FIR_BFFR .set 16 ; FIR buffer sizeK_FIR_INDEX .set 1 ; index countK_FRAME_SIZE .set 256 ; buffer sizeFIR_DP .usect fir_vars,0 fir_coff_table .usect fir_coff,20d_data_buffer .usect fir_bfr,40 ; buffer size for the filter d_filin .usect fir_in,256; d_filout .usect fir_out,256.def fir_init ; initialize FIR filter.def fir_task ; perform FIR filteringSTM #0,SWWSRSSBX FRCTfir_init: STM #d_filin,AR6 STM #d_filout,AR7 STM #fir_coff_table,AR5 RPT #K_FIR_BFFR-1 MVPD #COFF_FIR_START,*AR5+ STM #K_FIR_INDEX,AR0 STM #d_data_buffer,AR4 ; load cir_bfr address for the recent samples RPTZ A,#K_FIR_BFFR STL A,*AR4+ ; reset the buffer STM #(d_data_buffer+K_FIR_BFFR-1), AR4 ;RETD STM #fir_coff_table, AR5fir_task: ;LD #FIR_DP,DP STM #K_FRAME_SIZE-1,BRC ; Repeat 256 times RPTBD fir_filter_loop-1 STM #K_FIR_BFFR,BK ; FIR circular bffr size LD *AR6+, A ; load the input valuefir_filter: STL A,*AR4+% ; replace oldest sample with newest sample RPTZ A,(K_FIR_BFFR-1) MAC *AR4+0%,*AR5+0%,A ; filtering STH A, *AR7+ ; replace the oldest bffr valuefir_filter_loop nop nop nop ;RETend .end数字振荡器 #include cpu_reg.h#define LEN 512int ms,f;int con_buf=0;float bufLEN; /* save out wave buffer ! */ /* 0.1float y0 = 0;float y1 = 0.58778525229;float y2 = 0.95105651629; const float aa = 1.61803398875;const float bb = -1.;*/* 0.4float y0 = 0;float y1 = 0.58778525229;float y2 = -0.95105651629; const float aa = -1.61803398875;const float bb = -1.;*/ 0.01float y0 = 0;float y1 = 0.06279051953;float y2 = 0.12533323357; const float aa = 1.99605345686;const float bb = -1.;void main() memset(buf,0,LEN*sizeof(float); asm( STM #0000h,CLKMD ); while(*CLKMD & 0x01 ); asm( STM #40C7h,CLKMD ); /设置CPU运行频率100M/* 40C7h:5*clkin =100M 30c7h:4*clkin =80M 20c7h:3*clkin =60M 10C7h:2*clkin =40M*/ asm( stm #4240h, SWWSR ); /2 wait except for on-chip program 1 asm( stm #00a0h, PMST ); /MP/MC = 0, IPTR = 001,ovly=1 asm( stm #0802h, BSCR ); asm( STM #0h,IMR ); asm( STM #0010h,TCR ); /关定时器/ asm( STM #0186ah,PRD );/1ms/ asm( STM #0C2fh,TCR ); /TCR=最后四位 asm( STM #0270Fh,PRD );/1ms asm( STM #0C20h,TCR ); /TCR=最后四位 asm( STM #0008h,IFR ); asm( ORM #0008h,*(IMR) );/*开时间中断*/ asm( RSBX INTM ); /*开中断*/ f=2; ms=0; while(1) while(ms500/f); /LED_flash ms=0; asm( RSBX XF ); while(ms500/f); ms=0; asm( SSBX XF ); interrupt void timer0()y0 = aa*y2 + bb*y1;y1 = y2;y2 = y0; bufcon_buf=y0;con_buf+;if(con_buf = LEN) con_buf=0; /* set breakpoint to show wave ! */ ms+;放大器/ */ Description: This application uses Probe Points to obtain input/ (a sine wave). It then takes this signal, and applies a gain/ factor to it./ Filename: Sine.c/ *#include #include sine.h/ gain control variable int gain = INITIALGAIN; / declare and initalize a IO buffer BufferContents currentBuffer;/ Define some functions static void processing();/ process the input and generate output static void dataIO();/ dummy function to be used with ProbePointvoid main()puts(SineWave example started.n); while(TRUE) / loop forever /* Read input data using a probe-point connected to a host file. Write output data to a graph connected through a probe-point. */ dataIO(); /* Apply the gain to the input to obtain the output */ processing(); /* * FUNCTION:Apply signal processing transform to input signal * to generate output signal * PARAMETERS: BufferContents struct containing input/output arrays of size BUFFSIZE * RETURN VALUE: none. */static void processing() int size = BUFFSIZE; while(size-) currentBuffer.outputsize = currentBuffer.input

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论