Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
- x (n -i)
N
=0
The filter design can be implemented with a set of coefficients known with the number of delays
sample. Open MATLAB and type sptool, which should cause startup.spt window to open as
shown below.
3
Click on New under the Filters menu to start a new filter design session. Enter the filter
characteristics that you want or as shown below.
The configuration shown here is a band pass FIR filter for respective pass and stop
frequencies. The order is changed to 80 to have a steep fall in the transition band also having low
ripple factor. Push Design Filter to build the required data structure which can be used in the
workspace later on.
Go back to sptool window, select File Export file, and export to workspace. Execute the
snippet below to have the coefficients in a comma separated value format (easy to paste in CCS
project).
coeffs = (filt1.tf.num)*(2^15);
csvwrite('coeffs.dat',coeffs);
4
Open the directory where MATLAB saves all the files and find coeffs.dat. Open the file with
Notepad and copy all the contents to clipboard. These coefficients are used in the file called
bs2700.cof in CCS environment.
Create a new project with fir.c as the file with the program as shown below.
//fir.c FIR filter. Include coefficient file with length N
#include "bs2700.cof" //coefficient file
#include "dsk6713_aic23.h" //codec-dsk support file
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
int yn = 0; //initialize filter's output
short dly[N]; //delay samples
interrupt void c_int11() //ISR
{
short i;
dly[0]=input_sample(); //input newest sample
yn = 0; //initialize filter's output
for (i = 0; i< N; i++)
yn += (h[i] * dly[i]); //y(n) += h(i)* x(n-i);
for (i = N-1; i > 0; i--) //starting @ end of buffer
dly[i] = dly[i-1]; //update delays with data move
output_sample(yn >> 15); //scale output filter sample
return;
}
void main()
{
comm_intr(); //init DSK, codec, McBSP
while(1); //infinite loop
}
//bs2700.cof FIR band pass coefficients designed with MATLAB
#define N 81 //number of coefficients
hort h[N]={268.53,3462.3,-881.55,-390.55,-
82.85
528.38
99.43,-592.86,-221.23,64.94,157.98,41.137,-215.18,-478.74,-
1.15,-528.38,-
xecuting the program gives the desired response of a band pass filter with pass band ~ (1.1 5
s
1 ,134.71,508.42,873.36,1138.8,1211.4,1059.8,702.95,229.99,-221.44,-
,-611.15,-478.74,-215.18,41.137,157.98,64.94,-221.23,-592.86,-899.43,-
1007.1,-864.62,-533.21,-173.64,8.8679,-148.41,-688.69,-1494.3,-2302.1,-2780,-
2634,-1723.5,-125.28,1861,3787.9,5183.7,5692.9,5183.7,3787.9,1861,-125.28,-
1723.5,-2634,-2780,-2302.1,-1494.3,-688.69,-148.41,8.8679,-173.64,-533.21,-
864.62,-1007.1,-8
61
221.44,229.99,702.95,1059.8,1211.4,1138.8,873.36,508.42,134.71,-182.85,-
390.55,-881.55,3462.3,268.53
};
E
KHz).
C6713 Report Uday Kiran Thummalapalli
return;
//return from interrupt
}
void main()
{
comm_intr(); //init DSK, codec,
McBSP
while(1); //infinite loop
}
A C-callable assembler linker file has been created which can toggle the register value with
respective to flag passed to it.
;Timemux.asm Assembly function called from C to interlace MICROPHONE and
LINE IN
.def _Timemux ;asm function called from C
_Timemux: NOT A4,A1
;SUB A1,1,A1 ;decrement loop count
[A1] MVK .S1 0x0011,A0 ;LINE IN Instead of A0 find the reister
value for AIC23 control resiter 4
[!A1] MVK .S1 0x0014,A0 ;MICROPHONE
MV A1,A4
B B3 ;return to calling routine
NOP 5 ;five NOPs for delay slots
.end
Executing the above program results an audio out with interlaced audio signal and MIC input
signal.