Vous êtes sur la page 1sur 13

Implement Infinite Impulse

Response Low pass filter in DSK6713

Table of Contents

Abstract

___________________________ page 3

Introduction ___________________________ page 4 - 6


Procedures ___________________________ page 6 - 12
Conclusion ____________________________ page 13
References ____________________________ page 13

Abstract:

Signal processing concepts are often presented in a very mathematical and abstract format. This
can discourage students from further exploration because of the apparent irrelevance to the realworld problems. A common solution is to provide a hands-on laboratory to illustrate the
applications of abstract concepts. However, hardware-based digital signal processing (DSP)
laboratories which are typically incorporated into senior-level signal processing courses
usually emphasize programming the DSP chip rather than exploring algorithms and
applications.
This project combines the implementation of 3000Hz and 7000Hz infinite impulse response
(IIR)low pass filter using DSPtool TMS320C6713 DSK by using the Code Composer Studio 3.1v
for programming and the same is verified using CRO(Cathode Ray Oscilloscope).

Introduction:
DSP techniques have been very successful because of the development of low-cost software
and hardware support. For example, modems and speech recognition can be less expensive
using DSP techniques. DSP processors are concerned primarily with real-time signal
processing. Real-time processing requires the processing to keep pace with some external event,
whereas non-real-time processing has no such timing constraint. The external event to keep
pace with is usually the analog input. Whereas analog-based systems with discrete electronic
components such as resistors can be more sensitive to temperature changes, DSP-based systems
are less affected by environmental conditions. DSP processors enjoy the advantages of
microprocessors. They are easy to use, flexible, and economical.

The input signal to the TI DSK 6713 board is sampled in the AIC23 module. The AIC23 was an
ADC section and a DAC section. The DSP reads a unsigned integer 32 (Unit32) value of A/D via
the McBsp providing the value present at line input jack. The DSP writes a Uint32 to AIC23
where it contains values for left and right channels. The DSP is designed to do the FIR math
very fast, allowing real-time computations to live signals to line input.

Figure 2DSK TMS320C6713 circuit board

Figure 3 Block diagram of DSK TMS320C6713

The DSK board device used in this project comes with a wide variety of
application environments. Key features include:

A Texas Instruments TMS320C6713 DSP operating at 225 MHz.


An AIC23 stereo codec
16 Mbytes of synchronous DRAM
512 Kbytes of non-volatile Flash memory (256 Kbytes usable in default
configuration)
4 user accessible LEDs and DIP switches
Software board configuration through registers implemented in CPLD
Configurable boot options
Standard expansion connectors for daughter card use
JTAG emulation through on-board JTAG emulator with USB host
interface or external emulator
Single voltage power supply (+5V)

In this report DIP switches are used to send signal for each event based on the C code. The C
code is also attached in this report. The switch combination application explains what the C
code will do to the signal input.

Procedures:
Procedures of the demo are listed as follows:
1. Create a project for the CCS: Choose ProjectNewto create a new project file and save it. The
CCS uses the project to operate its built-in utilities to create a full-build application.

2. Create C program files using the CCS editor: Choose FileNewto create a new file, type in the C
code and save it as a C source file.

3. Create a linker command file for the simulator: The command file (with extension .cmd) is used by
the linker to map different program segments into a prepartitioned system memory space.

4. Setting up the project: Add the C and cmd files to the project by choosingProjectAddFiles to
Project. Programs written in C language require the use of the run-time support library, either rts55.lib or
rts55x.lib, for system initialization. This can be done by selecting the compiler and linker dialog box and
entering the C55x run-time support library, rts55.lib, and adding the header file path related to the source
file directory.

5. Build and run the program: Use ProjectRebuild All command to build the project. If there
are no errors, the CCS will generate the executable output file(extension .out). Before we can run the
program, we need to load the executable output file to the C55x DSK or the simulator. To do so, use
FileLoad Program menu and select the .outfile and load it. Execute this program by choosing
DebugRun. The processor status at the bottom-left-hand corner of the CCS will change from
CPUHALTED to CPU RUNNING. The running process can be stopped by the
DebugHaltcommand. We can continue the program by reissuing the Run command or exiting the
DSK or the simulator by choosing FileExitmenu.

C-program to implement IIR Low Pass Filter (fc=3k)


#include "dsk6713.h"
#include "dsk6713_aic23.h"
constsignedintfilter_Coeff[]=
{34,69,34,32768,-27535,6172,32768,65695,32928,32768,
-30894,10923,32768,65377,32609,32768,-39172,22630};
// Codec configuration settings
DSK6713_AIC23_Config config={\
0x0017, //0. DSK6713_AIC23_LEFTINVOl left line input channel volume
0x0017, //1. DSK6713_AIC23_RIGHTINVOl right line input channel volume
0x00d8, //2. DSK6713_AIC23_LEFTHPVOL left channel headphone volume
0x00d8, //3. DSK6713_AIC23_RIGHTHPVOL right channel headphone volume
0x0011, //4. DSK6713_AIC23_ANAPATH Analog audio path control
0x0000, //5. DSK6713_AIC23_DIGPATH Digital audio path control
0x0000, //6. DSK6713_AIC23_POWERDOWN Power down control
0x0043, //7. DSK6713_AIC23_DIGIF Digital audio interface
0x0081, //8. DSK6713_AIC23_SAMPLERATE Sample rate control
0x0001, //9. DSK6713_AIC23_DIGACT Digital interface activation
};

void main()
{
DSK6713_AIC23_CodecHandle hCodec;
intl_input, l_output, r_input, r_output;
//initialize board support library
DSK6713_init();
hCodec = DSK6713_AIC23_openCodec(0,&config);
DSK6713_AIC23_setFreq(hCodec,3);
while(1)
{
/* read a sampleto the left channel*/
while(!DSK6713_AIC23_read(hCodec, &l_input));
/* read a sample to the right channel*/
while(!DSK6713_AIC23_read(hCodec,&r_input));
l_output = IIR_FILTER(&filter_Coeff, l_input);
r_output = l_output;
// send sample to the left channel
while(!DSK6713_AIC23_write(hCodec, l_output));
// send sample to the left channel
while(!DSK6713_AIC23_write(hCodec,r_output));
}
// Close the codec
DSK6713_AIC23_closeCodec(hCodec);
}
signed intIIR_FILTER(const signed *h, signed intx1)
{
static signed intx[6]={0,0,0,0,0,0}; //x[n], x[n-1], x[n-2]
static signed inty[6]={0,0,0,0,0,0}; // y[n], y[n-1], y[n-2]
inttemp=0;
temp=(short int)x1; // copy input to temp
x[0]=(signed int)temp; // copy input to x[stages][0]
temp=((int)h[0]*x[0]); // B0*x[n]
temp=temp+((int)h[1]*x[1]); //B1/2 * x[n-1]
temp=temp+((int)h[1]*x[1]); //B1/2 * x[n-1]
temp=temp+((int)h[2]*x[2]); //B2 * x[n-2]
temp=temp-((int)h[4]*y[1]); //A1/2 * y[n-1]
temp=temp-((int)h[4]*y[1]); //A1/2 * y[n-1]
temp=temp-((int)h[5]*y[2]); //A2 * y[n-2]
// dividing temp by coefficient A0
temp>>=15;
if(temp>32767)
{
temp=32767;
}
else if(temp<-32767)
{
temp=-32767;
}
y[0]=temp;
// Shuffle values along one place for next time
y[2]=y[1]; // y[n-2]=y[n-1]
y[1]=y[0]; // y[n-1]=y[n]
x[2]=x[1]; // x[n-2]=x[n-1]
x[1]=x[0]; // x[n-1]=x[n]
// temp is used as input next time through
return(temp<<2);
}

C-program to implement IIR Low Pass Filter (fc=7k)


#include "dsk6713.h"
#include "dsk6713_aic23.h"
const signed intfilter_Coeff[]=
{2009,4018,2009,32768,8775,1136,32768,65693,32926,32768,10078,6172,32768,65379,
32611,32768,13570,19661};
// Codec configuration settings
DSK6713_AIC23_Config config={\
0x0017, //0. DSK6713_AIC23_LEFTINVOl left line input channel volume
0x0017, //1. DSK6713_AIC23_RIGHTINVOl right line input channel volume
0x00d8, /
/2. DSK6713_AIC23_LEFTHPVOL left channel headphone volume
0x00d8, //3. DSK6713_AIC23_RIGHTHPVOL right channel headphone volume
0x0011, //4. DSK6713_AIC23_ANAPATH Analog audio path control
0x0000, //5. DSK6713_AIC23_DIGPATH Digital audio path control
0x0000, //6. DSK6713_AIC23_POWERDOWN Power down control
0x0043, //7. DSK6713_AIC23_DIGIF Digital audio interface
0x0081, //8. DSK6713_AIC23_SAMPLERATE Sample rate control
0x0001, //9. DSK6713_AIC23_DIGACT Digital interface activation
};
void main()
{
DSK6713_AIC23_CodecHandle hCodec;
intl_input, l_output, r_input, r_output;
//initialize board support library
DSK6713_init();
hCodec = DSK6713_AIC23_openCodec(0,&config);
DSK6713_AIC23_setFreq(hCodec,3);
while(1)
{
/* read a sampleto the left channel*/
while(!DSK6713_AIC23_read(hCodec, &l_input));
/* read a sample to the right channel*/
while(!DSK6713_AIC23_read(hCodec,&r_input));
l_output = IIR_FILTER(&filter_Coeff, l_input);
r_output = l_output;
// send sample to the left channel
while(!DSK6713_AIC23_write(hCodec, l_output));
// send sample to the left channel
while(!DSK6713_AIC23_write(hCodec,r_output));
}
// Close the codec
DSK6713_AIC23_closeCodec(hCodec);
}
signed intIIR_FILTER(const signed *h, signed intx1)
{
static signed intx[6]={0,0,0,0,0,0}; //x[n], x[n-1], x[n-2]
static signed inty[6]={0,0,0,0,0,0}; // y[n], y[n-1], y[n-2]
inttemp=0;
temp=(short int)x1; // copy input to temp
x[0]=(signed int)temp; // copy input to x[stages][0]
temp=((int)h[0]*x[0]); // B0*x[n]
temp=temp+((int)h[1]*x[1]); //B1/2 * x[n-1]
temp=temp+((int)h[1]*x[1]); //B1/2 * x[n-1]

temp=temp+((int)h[2]*x[2]);
temp=temp-((int)h[4]*y[1]);
temp=temp-((int)h[4]*y[1]);
temp=temp-((int)h[5]*y[2]);

//B2 *
//A1/2
//A1/2
//A2 *

x[n-2]
* y[n-1]
* y[n-1]
y[n-2]

// dividing temp by coefficient A0


temp>>=15;
if(temp>32767)
{
temp=32767;
}
else if(temp<-32767)
{
temp=-32767;
}
y[0]=temp;
// Shuffle values along one place for next time
y[2]=y[1]; // y[n-2]=y[n-1]
y[1]=y[0]; // y[n-1]=y[n]
x[2]=x[1]; // x[n-2]=x[n-1]
x[1]=x[0]; // x[n-1]=x[n]
// temp is used as input next time through
return(temp<<2);
}

To generate Coefficients from Matlab :


SPTool
1. From MATLAB, type the following:
>>SPToolto access MATLABs GUI filter designer SPTool for the IIR filters.
2. From the startup window startup.spt, select a new design and use the
characteristics shown in Figureto design an IIR low pass filter with cut off frequency
of 3000 Hz.
3. Access the startup window again. Select AEditAName. Change the name
(enter new variable name) filt1.
4. Select File AExport A Export to Workspace the filt1design.
5. Access MATLABs workspace and type the following two commands
>>[z,p,k] = tf2zp(filt1.tf.num, filt1.tf.den);
>>sec_ord_sec= zp2sos(z,p,k);
>>sec_ord_sec= round(sec_ord_sec*2^15)to find the numerator coefficients of the transfer function.

These coefficients are in a float format. The second command scales these coefficients by 2^15 so
that they can be used for a fixed-point implementation. The scaled coefficients of the IIR low pass filter
should be listed within the workspace as shown.

10

Response of 3K IIR LPF

Coefficients for 3k IIR LPF


11

Response of 7K IIR LPF

Coefficients for 7k IIR LPF


12

Conclusion:
The required IIR Low Pass Filter with frequencies 3000 Hz and 7000 Hz has
been designed and verified using Cathode Ray Oscilloscope.

References:
Digital Signal Processing and Applications with C6713 and C6714 DSK byRulph Chassaing
Texas Instruments, TMS320VC5510/5510A, Fixed-Point Digital Signal
Processors, DataManual, Dallas, TX, July 2006
University of Rochester, DSP Architectures: Past, Present and Future,
http://www.ece.rochester.edu/research/wcng/papers/CAN_r1.pdf.

13

Vous aimerez peut-être aussi