Function: Implement a high-pass, low-pass,
band-pass, and band-stop FIR filter of voice/music on
the C54x DSKPlus
Location: ftp://ftp.ti.com/pub/tms320bbs/c5xxdskfiles/Fir.exe
By:
Thomas Millikan
FIR Application Code: dskpfir.exe
Starting off:
The file "dskpfir.exe" can be downloaded from the above listed ftp site to provide a demonstration of "Real Convolution" or FIR filtering on the C54x DSK Plus. First save "dskpfir.exe" into it’s own directory. Then run the executable (either in DOS or Windows) allowing it to explode into the following list of files:
dskpfir.exe - The original file that was downloaded Ac01init.asm - Initializes the analog interface on the DSK Plus Bandpass\ Bandpass.asm - Main assembly program Bandpass.lst - list file containing variable names Bandpass.obj - object file for main assembly program (executable) Readme.txt - In depth explanation of the assembly code Coeff.asm - Initializes coefficients for filters Vectors.asm - Initializes the C542 interrupt vector table Note: The other various filters (i.e. Bandstop, Lowpass, and Highpass) all burst into separate folders with identical file types.
By downloading and running the files in "dskpfir.exe" you now have the capability to manipulate and control audio signals. All of the filtering programs included in this file control different parts of the frequency spectrum. By familiarizing yourself with these files and understanding how they work, you can begin to manipulate audio signals in limitless ways.
Download any of the four object files: Bandpass.obj, Bandstop.obj, Lowpass.obj, or Highpass.obj onto the DSK to hear the effects of the various filters.
To aide in evaluating these filters, we have include a random noise generator which enables you to test the output with an oscilloscope. With the random noise generator operational, no input is needed to test the filtering programs. To remove the random noise generator, see the hints section.
After removing the random noise generator , the music/voice is input through the "IN" mini-jack, filtered by the DSP, and then played through the "OUT" mini-jack. (see the TMS320C54x DSKPlus User’s Guide page 1-4 for jack locations)
Theory:
With an input of voice/music these programs output a selected frequency band of the voice/music. The relationship between the input and the output of an FIR filter can be understood through the equation:
![]()
- y[n] is the current output
- x[n] is the current input, and x[n-k] are previous inputs
- bk are the filter coefficients or gains.
- M = the # of taps, which is also equal to the # of past inputs you must store.
The coefficients, bk, are constants that describe the filter’s behavior. All of the filtering programs are 80 tap (M=80) filters. The cutoff frequencies for the various filters are:
Bandpass: - Allows frequencies between 960Hz and 2,160Hz Bandstop - Blocks frequencies between 960Hz and 2,160Hz Highpass - Allows frequencies between 2,520Hz and 4,629Hz Lowpass - Allows frequencies between 0Hz and 1,000Hz
All of these filters are designed to run at a sampling frequency of 9,259 Hz. If you decide to change the sampling frequency in these programs, it will affect the cutoff frequencies of the filters. Each main assembly file has the equations necessary to calculate the new cutoff frequencies.
Hints:
To change the sampling frequency, look to the lines:File: "Ac01init.asm" REG1 .set 124h REG2 .set 20fh The sampling frequency is defined by: Sampling Frequency = MCLK/ ( 2 * A * B) where: MCLK = 10Mhz A = Bits 0 to 8 of REG1 (for example: REG1 = 124, then A = 24) B = Bits 0 to 8 of REG2 (for example: REG2 = 20f, then B= 0f)Refer to page 2-20 in the "TLC320AC01C User’s Manual" for more information.
To change the # of taps in the filter, You must edit 3 things.
First, You must reserve as many data locations as you have taps. File: "Bandpass.asm" XN .word 0,0,0,0,0,0,0,0,0,0;80 data locations for 80 XN1 .word 0,0,0,0,0,0,0,0,0,0 ;stage delay lineTo reserve more space, simply insert more lines similar to the ones you see above, between XN and XNLAST. Make sure that XN is the first memory location, and XNLAST is the last location
Second, You must change the number of times you calculate the coefficients and inputs.
File: "Bandpass.asm" repeat (#79)Change the repeat count to equal the number of taps - 1, or (M-1) For example, our filter had 80 taps, so the repeat count equals (80-1) or 79
Third, You must enter your new coefficients into the Coeff.asm file.
File: "Coeff.asm" h0 .word 0 h1 .word -157The file "Coeff.asm" contains all of the coefficients for your filter. You should put your new coefficients in this file following the above format. (i.e. hN .word coefficient #N) Make sure that the label "h0" is attached to the first coefficient in your file.
To remove the random noise generator, look to the lines:
File: "Bandpass.asm" ;--------- random noise Generator (P-5cs Modulator)------------------- a = @seed << 1 ............... a = a <Simply insert a semicolon in front of all the assembly code under this section.