.copy "v:\ece320\54x\dsplib\core.asm" ; Copy in core code ;WAH AUDIO EFFECT CODE ;ECE320 DSP LAB (SPRING 2001) ;PIYA POONGBUNKOR AND VICERUT NONZEE FIR_len .set 20 ; Set length for 20-tap filter. .sect ".data" ; Flag following as data declarations .align 32 ; Align to a multiple of 32 coef1 .copy "w:\finalcoef\coef1.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef2 .copy "w:\finalcoef\coef2.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef3 .copy "w:\finalcoef\coef3.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef4 .copy "w:\finalcoef\coef4.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef5 .copy "w:\finalcoef\coef5.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef6 .copy "w:\finalcoef\coef6.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef7 .copy "w:\finalcoef\coef7.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef8 .copy "w:\finalcoef\coef8.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef9 .copy "w:\finalcoef\coef9.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef10 .copy "w:\finalcoef\coef10.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef11 .copy "w:\finalcoef\coef11.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef12 .copy "w:\finalcoef\coef12.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef13 .copy "w:\finalcoef\coef13.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef14 .copy "w:\finalcoef\coef14.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef15 .copy "w:\finalcoef\coef15.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef16 .copy "w:\finalcoef\coef16.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef17 .copy "w:\finalcoef\coef17.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef18 .copy "w:\finalcoef\coef18.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef19 .copy "w:\finalcoef\coef19.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef20 .copy "w:\finalcoef\coef20.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef21 .copy "w:\finalcoef\coef21.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef22 .copy "w:\finalcoef\coef22.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef23 .copy "w:\finalcoef\coef23.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef24 .copy "w:\finalcoef\coef24.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef25 .copy "w:\finalcoef\coef25.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef26 .copy "w:\finalcoef\coef26.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef27 .copy "w:\finalcoef\coef27.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef28 .copy "w:\finalcoef\coef28.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef29 .copy "w:\finalcoef\coef29.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef30 .copy "w:\finalcoef\coef30.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 coef31 .copy "w:\finalcoef\coef31.asm" ; Copy in coefficients .align 32 ; Align to a multiple of 32 firstate .space 16*20 ; Allocate 20 words of storage gain .word 20000 ; Set gain value begin .word 0 ; Set starting counter value NUMBYTES .set 1 ; Set NUMBYTES = 1 to read one byte .sect ".data" ; Flag following as data declarations data_buf .space NUMBYTES*16 ; allocate NUMBYTES words for ; serial data buffer data_ptr .word data_buf ; data_ptr initialized to store address ; of first word in serial data buffer ; filter state. .sect ".text" main ; Initialize address registers stm #FIR_len,BK ; initialize circular buffer length stm #coef1,AR2 ; initialize coefficient pointer stm #firstate,AR3 ; initialize state pointer stm #1,AR0 ; initialize AR0 for pointer increment ld #0h,A ; initialize counter Accum A to 0 stm #begin,AR4 ; initialize AR4 for counter comparison stm #gain,AR5 ; initialize AR5 for gain value loop ; Wait for a new block of 64 samples to come in WAITDATA addm #1h,*AR4 ; add 1 to count in *AR4 cmpm *AR4,#0x7d0 ; compare to 2000 samples bc wah1,TC ; branch to wah1 if TC = 1 cmpm *AR4,#0xfa0 ; compare to 4000 samples bc wah2,TC ; branch to wah2 if TC = 1 cmpm *AR4,#0x1770 ; compare to 6000 samples bc wah3,TC ; branch to wah3 if TC = 1 cmpm *AR4,#0x1f40 ; compare to 8000 samples bc wah4,TC ; branch to wah4 if TC = 1 cmpm *AR4,#0x2710 ; compare to 10000 samples bc wah5,TC ; branch to wah5 if TC = 1 cmpm *AR4,#0x2ee0 ; compare to 12000 samples bc wah6,TC ; branch to wah6 if TC = 1 cmpm *AR4,#0x36b0 ; compare to 14000 samples bc wah7,TC ; branch to wah7 if TC = 1 cmpm *AR4,#0x3e80 ; compare to 16000 samples bc wah8,TC ; branch to wah8 if TC = 1 cmpm *AR4,#0x4650 ; compare to 18000 samples bc wah9,TC ; branch to wah9 if TC = 1 cmpm *AR4,#0x4e20 ; compare to 20000 samples bc wah10,TC ; branch to wah10 if TC = 1 cmpm *AR4,#0x55f0 ; compare to 22000 samples bc wah11,TC ; branch to wah11 if TC = 1 cmpm *AR4,#0x5dc0 ; compare to 24000 samples bc wah12,TC ; branch to wah12 if TC = 1 cmpm *AR4,#0x6590 ; compare to 26000 samples bc wah13,TC ; branch to wah13 if TC = 1 cmpm *AR4,#0x6d60 ; compare to 28000 samples bc wah14,TC ; branch to wah14 if TC = 1 cmpm *AR4,#0x7530 ; compare to 30000 samples bc wah15,TC ; branch to wah15 if TC = 1 cmpm *AR4,#0x7d00 ; compare to 32000 samples bc wah16,TC ; branch to wah16 if TC = 1 cmpm *AR4,#0x84d0 ; compare to 34000 samples bc wah17,TC ; branch to wah17 if TC = 1 cmpm *AR4,#0x8ca0 ; compare to 36000 samples bc wah18,TC ; branch to wah18 if TC = 1 cmpm *AR4,#0x9470 ; compare to 38000 samples bc wah19,TC ; branch to wah19 if TC = 1 cmpm *AR4,#0x9c40 ; compare to 40000 samples bc wah20,TC ; branch to wah20 if TC = 1 cmpm *AR4,#0xa410 ; compare to 42000 samples bc wah21,TC ; branch to wah21 if TC = 1 cmpm *AR4,#0xabe0 ; compare to 44000 samples bc wah22,TC ; branch to wah22 if TC = 1 cmpm *AR4,#0xb3b0 ; compare to 46000 samples bc wah23,TC ; branch to wah23 if TC = 1 cmpm *AR4,#0xbb80 ; compare to 48000 samples bc wah24,TC ; branch to wah24 if TC = 1 cmpm *AR4,#0xc350 ; compare to 50000 samples bc wah25,TC ; branch to wah25 if TC = 1 cmpm *AR4,#0xcb20 ; compare to 52000 samples bc wah26,TC ; branch to wah26 if TC = 1 cmpm *AR4,#0xd2f0 ; compare to 54000 samples bc wah27,TC ; branch to wah27 if TC = 1 cmpm *AR4,#0xdac0 ; compare to 56000 samples bc wah28,TC ; branch to wah28 if TC = 1 cmpm *AR4,#0xe290 ; compare to 58000 samples bc wah29,TC ; branch to wah29 if TC = 1 cmpm *AR4,#0xea60 ; compare to 60000 samples bc wah30,TC ; branch to wah30 if TC = 1 cmpm *AR4,#0xf230 ; compare to 62000 samples bc wah31,TC ; branch to wah31 if TC = 1 b filter wah1 ;load and run corresponding filter coeff stm #coef1,AR2 b filter wah2 ;load and run corresponding filter coeff stm #coef2,AR2 b filter wah3 ;load and run corresponding filter coeff stm #coef3,AR2 b filter wah4 ;load and run corresponding filter coeff stm #coef4,AR2 b filter wah5 ;load and run corresponding filter coeff stm #coef5,AR2 b filter wah6 ;load and run corresponding filter coeff stm #coef6,AR2 b filter wah7 ;load and run corresponding filter coeff stm #coef7,AR2 b filter wah8 ;load and run corresponding filter coeff stm #coef8,AR2 b filter wah9 ;load and run corresponding filter coeff stm #coef9,AR2 b filter wah10 ;load and run corresponding filter coeff stm #coef10,AR2 b filter wah11 ;load and run corresponding filter coeff stm #coef11,AR2 b filter wah12 ;load and run corresponding filter coeff stm #coef12,AR2 b filter wah13 ;load and run corresponding filter coeff stm #coef13,AR2 b filter wah14 ;load and run corresponding filter coeff stm #coef14,AR2 b filter wah15 ;load and run corresponding filter coeff stm #coef15,AR2 b filter wah16 ;load and run corresponding filter coeff stm #coef16,AR2 b filter wah17 ;load and run corresponding filter coeff stm #coef17,AR2 b filter wah18 ;load and run corresponding filter coeff stm #coef18,AR2 b filter wah19 ;load and run corresponding filter coeff stm #coef19,AR2 b filter wah20 ;load and run corresponding filter coeff stm #coef20,AR2 b filter wah21 ;load and run corresponding filter coeff stm #coef21,AR2 b filter wah22 ;load and run corresponding filter coeff stm #coef22,AR2 b filter wah23 ;load and run corresponding filter coeff stm #coef23,AR2 b filter wah24 ;load and run corresponding filter coeff stm #coef24,AR2 b filter wah25 ;load and run corresponding filter coeff stm #coef25,AR2 b filter wah26 ;load and run corresponding filter coeff stm #coef26,AR2 b filter wah27 ;load and run corresponding filter coeff stm #coef27,AR2 b filter wah28 ;load and run corresponding filter coeff stm #coef28,AR2 b filter wah29 ;load and run corresponding filter coeff stm #coef29,AR2 b filter wah30 ;load and run corresponding filter coeff stm #coef30,AR2 b filter wah31 ;load and run corresponding filter coeff stm #coef31,AR2 stm #0,*AR4 b filter ; BlockLen = the number of samples that come from WAITDATA (64) filter stm #BlockLen-1, BRC ; Save repeat count into block repeat counter rptb endblock-1 ; Repeat between here and 'endblock' label ld *AR6,16, A ; Receive ch1 into A accumulator mar *+AR6(2) ; Rcv data is in every other channel ld A,B ; Transfer A into B for safekeeping ; The following code executes a single FIR filter. sth A,*AR3+% ; store current input into state buffer rptz A,(FIR_len-1) ; clear A and repeat mac *AR2+0%,*AR3+0%,A ; multiply coefficient by state & accumulate rnd A ; Round off value in 'a' to 16 bits mpya AR5 ; Multiply A by gain add B,A ; Add input to gained/filtered input sth A, *AR7 ; Store filter output (from a) into ch1 mar *+AR7(6) ; Output on all other channels endblock: _serial_stuff ; this block must only run once ; per WAITDATA call pshm AR3 ; we save AR3 so you don't have to mvdm data_ptr, AR3 ; set AR3 to point to last byte stored ; in the serial data buffer pshm AR0 ; we save AR0 so you don't have to stm #data_buf+NUMBYTES, AR0 ; #data_buf+NUMBYTES is the address of ; the last word in the ; serial data buffer nop ; increment PC cmpr eq, AR3 ; if last byte stored is at the last nop ; address in the serial data buffer, nop ; wrap to beginning of serial data xc 2, TC ; buffer stm #data_buf, AR3 READSER 1 ; copy one byte from ser_rxbuf to ; serial data buffer ; (ser_rxbuf initialized in core file ; and filled automatically when ; data arrives on serial port) mvmd AR3, data_ptr ; save address of last byte stored ; in serial data buffer popm AR0 ; we restore AR0 so you don't have to popm AR3 ; we restore AR3 so you don't have to mvdm data_ptr,AR5 ; serial information becomes gain value b loop