|
实现 基于vc33的fir滤波器:
;Serial Port 0 registers .global BEGIN sport .set 808040h ; Serial Port 0 global control register xpctrl .set 808042h ; FSX/DX/CLKX port control rpctrl .set 808043h ; FSR/DR/CLKR port control rxtctrl .set 808044h ; r/x timer control register rxtcnt .set 808045h ; r/x timer counter register rxtprd .set 808046h ; r/x period register xdata .set 808048h ; Data transmit register rdata .set 80804Ch ; Data receive register t0_GO .set 001cfh ; Timer configuration to GO giebit .set 2000h ; GIE bit in ST register eint3_cpu .set 08h ; Enable bit for INT3 in IE register int3_cpu_if .set 08h ; INT3 bit in IF register
.data s0_rxcntr .int 00000000h ; Serial Clock will be configured s0_rxprd .int 00020002h ; to run at 3.125 MHz sp0_cfg .word 0c140044h ; SP0 GCR configuration word adc_init .word 0000a000h ; ADC initialization word adc_cfg .word 0000a022h ; repeat mode configuration word adc_sel_0 .word 00000000h ; to read input channel 0 adc_sel_1 .word 00001000h ; to read input channel 1 fifo_read .word 0000e000h ; FIFO read command DP_reg .word 00800000h ; DP pointer startData .word 00809c10h ; start of data in RAM endData .word 00809d0fh ; end of data in RAM outnew_addr .word 00800d10h ; stack_addr .word 00800e0fh ; xn_addr .word xn hn_addr .word hn xnnew_addr .word 00809c14h ; hn .int 1,2 xn .int 3, 1 N .word 6
***************************************************** * Main Program ***************************************************** .text begin ldp DP_reg ; Load Data Page pointer ldi @stack_addr,sp ldi @N,bk ldi 4,rc ldp hn_addr ldi @hn_addr,ar0 ldi @xn_addr,ar1 ldi @xnnew_addr,ar2 ldi @outnew_addr,ar3 loop ldf *ar2,r6 stf r6,*ar1++(1)% call fir stf r0,*AR3 br loop ************************************************************************ * FIR ************************************************************************ fir mpyf3 *ar0++(1),*ar1++(1)%,r0 ; 初始化R0h(N-1)*x(n-(N-1))=R0 ldf 0.0,r2 ; 初始化R2 rpts rc ; 设置重复次数 mpyf3 *ar0++(1),*ar1++(1)%,r0 ; h(N-1-i)*x(n-(N-1-i))=R0 ||addf3 r0,r2,r2 ; 乘累加 addf3 r0,r2,r0 ; 加上最后一个乘积 rets ; 返回 .end
******************************************************************************** * Place assembly initialization routine and interrupt vectors here ******************************************************************************** .sect "vectors" b int_isr ********************************************************************************* .end ; end of repeat_mode
|