Download as pdf or txt
Download as pdf or txt
You are on page 1of 51

TMS320C6713 Lab Manual

TMS320C6713 DSP Starter Kit


(DSK)

LAB MANUAL

DIGITAL SHARK TECHNOLOGY

Digital Shark Technology Page 1


TMS320C6713 Lab Manual

Contents
i Installing Code Composer studio V3.3……………………………………………3

ii Creating new project…………………………………………………………………….6

1.Linear Convolution of two given sequence……………………………………..9

2.Circular Convolution of two given sequence………………………………….11

3.N point DFT ………………………………………………………………………………….15

4.Impulse response …………………………………………………………………………18

5.Tone……………………………………………………………………………………………..22

6.Square Wave generation………………….……………………………………….…..29

7.Audio loopback ………………………………………………………………………….…32

8.Voice Scrambling Using Filtering and Modulation………………………….43

9.FIR filter………………………………………………………………………………………..47

10.IIR filter……………………………………………………………………………………….50

Digital Shark Technology Page 2


TMS320C6713 Lab Manual

i. Installing Code composer studio

Download Windows virtual PC

Download Windows XP mode

Open 6713 DSK diagnostics utility v3.1 and conduct test, once passed
proceed the following

 Open Code composer studio v3.3

 Select Family  C67xx

Digital Shark Technology Page 3


TMS320C6713 Lab Manual

 Select 6713 Device cycle accurate simulator

Digital Shark Technology Page 4


TMS320C6713 Lab Manual

 Select Little endian. If little endian is not selected, building/linking


error can occur. Add it to the left panel. Save and quit.

Digital Shark Technology Page 5


TMS320C6713 Lab Manual

ii. Creating new project

1. Click Project  Project  New


Enter the details as shown in figure below

2. The new project will be saved in the folder


C:\CCStudio_v3.1\MyProjects\Demo
3. Create Source file
File New  Source file
Write the program in empty file and save as .c file
4. Add source file to project
This source file is stored in the folder Demo and must be added to the
project if it is to be used to generate the executable file Demo.out
Select Project  Add files to project and look for files of type (*.c,*.ccc) it
should appear in Project view window in the source folder as shown in
below figure.

Digital Shark Technology Page 6


TMS320C6713 Lab Manual

5. Add library support fi les rts6700.lib, dsk6713bsl.lib, and csl6713.lib to the


project.
Three more times, select Project→ Add Files to Project and look for Files of
Type Object and Library Files ( * .o * , * .l * ) The three library files are
stored in folders c:\CCStudio_v3.1\c6000\cgtools\lib,
c:\ CCStudio_v3.1\c6000\dsk6713\lib , and c:\CCStudio_v3.1\c6000\csl\lib,
respectively. These are the run - time support (for C67x architecture),
board support (for C6713 DSK), and chip support (for C6713 processor)
library files

6. Add the linker command file c6713dsk.cmd to the project.


Select Project→ Add Files to Project and look for Files of Type Linker
Command File ( * .cmd; * .lcf) . Open, or double - click on, c6713dsk.cmd . It
should then appear in the Project View window.

Digital Shark Technology Page 7


TMS320C6713 Lab Manual

7. The Project View window in CCS should look as shown in Figure below.
The GEL fi le dsk6713.gel is added automatically when you create the
project. It initializes the C6713 DSK invoking the board support library to
use the PLL to set the CPU clock to 225 MHz

Digital Shark Technology Page 8


TMS320C6713 Lab Manual

1. Linear Convolution
/* prg to implement linear convolution */
#include<stdio.h>
#include<math.h>
int y[20];
main()
{ int m=6; /*Lenght of i/p samples sequence*/
int n=6; /*Lenght of impulse response Co-efficients */
int i=0,j;
int x[15]={1,2,3,4,5,6,0,0,0,0,0,0}; /*Input Signal Samples*/
int h[15]={1,2,3,4,5,6,0,0,0,0,0,0}; /*Impulse Response
Coefficients*/
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
printf("Linear Convolution\n");
for(i=0;i<m+n-1;i++)
printf("%d\n",y[i]);
}

Digital Shark Technology Page 9


TMS320C6713 Lab Manual

Results
x = {1,2,3,4,5,6}
y = {1,2,3,4,5,6}
output = conv(x,y)={

Digital Shark Technology Page 10


TMS320C6713 Lab Manual

2. Circular Convolution
#include<stdio.h>
#include<math.h>
int m,n,x[30],h[30],y[30],i,j,temp[30],k,x2[30],a[30];
void main()
{
printf(" enter the length of the first sequence\n");
scanf("%d",&m);
printf(" enter the length of the second sequence\n");
scanf("%d",&n);
printf(" enter the first sequence\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf(" enter the second sequence\n");
for(j=0;j<n;j++)
scanf("%d",&h[j]);
if(m-n!=0) /*If length of both sequences are not equal*/
{
if(m>n) /* Pad the smaller sequence with zero*/

Digital Shark Technology Page 11


TMS320C6713 Lab Manual

{
for(i=n;i<m;i++)
h[i]=0;
n=m;
}
for(i=m;i<n;i++)
x[i]=0;
m=n;
}
y[0]=0;
a[0]=h[0];
for(j=1;j<n;j++) /*folding h(n) to h(-n)*/
a[j]=h[n-j];
/*Circular convolution*/
for(i=0;i<n;i++)
y[0]+=x[i]*a[i];
for(k=1;k<n;k++)
{
y[k]=0;

Digital Shark Technology Page 12


TMS320C6713 Lab Manual

/*circular shift*/
for(j=1;j<n;j++)
x2[j]=a[j-1];
x2[0]=a[n-1];
for(i=0;i<n;i++)
{
a[i]=x2[i];
y[k]+=x[i]*x2[i];
}
}
/*displaying the result*/
printf(" the circular convolution is\n");
for(i=0;i<n;i++)
printf("%d \t",y[i]);
}

Results

x1=[1 2 3 4];

x2=[4 3 2 1];

Digital Shark Technology Page 13


TMS320C6713 Lab Manual

n = 4;

y = 24 22 24 30

Digital Shark Technology Page 14


TMS320C6713 Lab Manual

3.N point DFT

#include<stdio.h>

#include<math.h>

void main()

short N = 8;

short x[8] = {1,2,3,4,5,6,7,0}; // test data

float pi = 3.1416;

float sumRe = 0, sumIm = 0; // init real/imag components

float cosine = 0, sine = 0; // Initialise cosine/sine components

// Output Real and Imaginary components

float out_real[8] = {0.0}, out_imag[8] = {0.0};

int n = 0, k = 0;

for(k=0 ; k<N ; k++)

Digital Shark Technology Page 15


TMS320C6713 Lab Manual

sumRe = 0;

sumIm = 0;

for (n=0; n<N ; n++)

cosine = cos(2*pi*k*n/N);

sine = sin(2*pi*k*n/N);

sumRe = sumRe + x[n] * cosine;

sumIm = sumIm - x[n] * sine;

out_real[k] = sumRe;

out_imag[k] = sumIm;

printf("[%d] %7.3f %7.3f \n", k, out_real[k], out_imag[k]);

Digital Shark Technology Page 16


TMS320C6713 Lab Manual

Results

N=8

x[8] = {1,2,3,4,5,6,7,0}

[0] 28.000 0.000


[1] -9.657 4.000
[2] -4.000 -4.000
[3] 1.657 -4.000
[4] 4.000 -0.000
[5] 1.657 4.000
[6] -4.000 4.000
[7] -9.657 -3.999

Digital Shark Technology Page 17


TMS320C6713 Lab Manual

4. Impulse response of first order and second order system

/*Impulse response of the system

y[n] + a1 y[n-1] + a2 y[n-2] + .. = b0 x[n] + b1 x[n-1]

+ b2 y[n-2] + ..

Example :

1 y[n] + 1 y[n-1] + 1 y[n-2] = 1 x[n] + 2 x[n-1] + 1 y[n-2]

*/

#include<stdio.h>

#define order 2 /*Order of the system*/

#define len 10 /*Length of the output pulses*/

float y[len]={0,0,0},sum;

main()

int j,k;

float a[order+1]={1,1,1};

/* y coefficients – may change in accordance with the difference

Digital Shark Technology Page 18


TMS320C6713 Lab Manual

equation */

float b[order+1]={1,2,1};

/* x coefficients – may change in accordance with the difference

equation */

for(j=0;j<len;j++)

sum=0;

for(k=1;k<=order;k++)

if((j-k)>=0)

sum=sum+(b[k]*y[j-k]);

if((j)<=order)

y[j]=a[j]-sum;

Digital Shark Technology Page 19


TMS320C6713 Lab Manual

else

y[j]=-sum;

printf("response[%d]=%f\n",j,y[j]);

Results

xcoeff = [1 1 1]
ycoeff = [1 2 1]
imp_resp = filter(xcoeff,ycoeff,[1 zeros(1,9)])
imp_resp = 1 -1 2 -3 4 -5 6 -7 8 -9
OUTPUT:
response[0]=1.000000
response[1]=-1.000000
response[2]=2.000000
response[3]=-3.000000
response[4]=4.000000

Digital Shark Technology Page 20


TMS320C6713 Lab Manual

response[5]=-5.000000
response[6]=6.000000
response[7]=-7.000000
response[8]=8.000000
response[9]=-9.000000

Digital Shark Technology Page 21


TMS320C6713 Lab Manual

5. Tone
Project  Open  browse
C:\CCStudio_v3.1\examples\dsk6713\bsl\tone\tone.pjt

/*
* ======== tone.c ========
*
* This example uses the AIC23 codec module of the 6713 DSK
Board Support
* Library to generate a 1KHz sine wave on the audio outputs
for 5 seconds.
* The sine wave data is pre-calculated in an array called
sinetable. The
* codec operates at 48KHz by default. Since the sine wave
table has 48
* entries per period, each pass through the inner loop takes 1
millisecond.
* 5000 passes through the inner loop takes 5 seconds.
*
* Please see the 6713 DSK help file under Software/Examples
for more
* detailed information.

Digital Shark Technology Page 22


TMS320C6713 Lab Manual

*/

/*
* DSP/BIOS is configured using the DSP/BIOS configuration
tool. Settings
* for this example are stored in a configuration file called
tone.cdb. At
* compile time, Code Composer will auto-generate DSP/BIOS
related files
* based on these settings. A header file called tonecfg.h
contains the
* results of the autogeneration and must be included for
proper operation.
* The name of the file is taken from tone.cdb and adding cfg.h.
*/
#include "tonecfg.h"

/*
* The 6713 DSK Board Support Library is divided into several
modules, each
* of which has its own include file. The file dsk6713.h must be
included

Digital Shark Technology Page 23


TMS320C6713 Lab Manual

* in every program that uses the BSL. This example also


includes
* dsk6713_aic23.h because it uses the AIC23 codec module.
*/
#include "dsk6713.h"
#include "dsk6713_aic23.h"

/* Length of sine wave table */


#define SINE_TABLE_SIZE 48

/* 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

Digital Shark Technology Page 24


TMS320C6713 Lab Manual

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
format
0x0001, // 8 DSK6713_AIC23_SAMPLERATE Sample rate
control
0x0001 // 9 DSK6713_AIC23_DIGACT Digital interface
activation
};

/* Pre-generated sine wave data, 16-bit signed samples */


Int16 sinetable[SINE_TABLE_SIZE] = {
0x0000, 0x10b4, 0x2120, 0x30fb, 0x3fff, 0x4dea, 0x5a81,
0x658b,
0x6ed8, 0x763f, 0x7ba1, 0x7ee5, 0x7ffd, 0x7ee5, 0x7ba1,
0x76ef,
0x6ed8, 0x658b, 0x5a81, 0x4dea, 0x3fff, 0x30fb, 0x2120,
0x10b4,
0x0000, 0xef4c, 0xdee0, 0xcf06, 0xc002, 0xb216, 0xa57f,
0x9a75,

Digital Shark Technology Page 25


TMS320C6713 Lab Manual

0x9128, 0x89c1, 0x845f, 0x811b, 0x8002, 0x811b, 0x845f,


0x89c1,
0x9128, 0x9a76, 0xa57f, 0xb216, 0xc002, 0xcf06, 0xdee0,
0xef4c
};

/*
* main() - Main code routine, initializes BSL and generates
tone
*/

void main()
{
DSK6713_AIC23_CodecHandle hCodec;
Int16 msec, sample;

/* Initialize the board support library, must be called first */


DSK6713_init();

/* Start the codec */

Digital Shark Technology Page 26


TMS320C6713 Lab Manual

hCodec = DSK6713_AIC23_openCodec(0, &config);

/* Generate a 1KHz sine wave for 5 seconds */


for (msec = 0; msec < 5000; msec++)
{
for (sample = 0; sample < SINE_TABLE_SIZE; sample++)
{
/* Send a sample to the left channel */
while (!DSK6713_AIC23_write(hCodec,
sinetable[sample]));

/* Send a sample to the right channel */


while (!DSK6713_AIC23_write(hCodec,
sinetable[sample]));
}
}

/* Close the codec */


DSK6713_AIC23_closeCodec(hCodec);
}

Digital Shark Technology Page 27


TMS320C6713 Lab Manual

Build, Connect the board and Run the program.


Results
Connect Speaker to Line OUT to hear tone

Digital Shark Technology Page 28


TMS320C6713 Lab Manual

6.Square Wave Generation


//Squarewave.c Generates a squarewave using a look-
up table
#include "dsk6713_aic23.h" //codec-DSK interface
support
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set
sampling rate

#define table_size (int)0x40 //size of table=64


short data_table[table_size]; //data table array
int i;

interrupt void c_int11() //interrupt service


routine
{
output_sample(data_table[i]); //output value each
Ts
if (i < table_size) ++i; //if table size is reached
else i = 0; //reinitialize counter
return; //return from interrupt

Digital Shark Technology Page 29


TMS320C6713 Lab Manual

main()
{
for(i=0; i<table_size/2; i++) //set 1st half of buffer
data_table[i] = 0x7FFF; //with max value
(2^15)-1
for(i=table_size/2; i<table_size; i++) //set 2nd half of
buffer
data_table[i] = -0x8000; //with -(2^15)

i = 0; //reinit counter
comm_intr(); //init DSK, codec, McBSP
while (1); //infinite loop
}

Results
An successful execution of program the square wave is
generated as shown in figure below

Digital Shark Technology Page 30


TMS320C6713 Lab Manual

Digital Shark Technology Page 31


TMS320C6713 Lab Manual

7. Audio Loopback
Project  Open  browse
C:\CCStudio_v3.1\examples\dsk6713\csl\mcbsp\mcbsp1
/*
* ======== tsk_audio.c ========
*
* This example demonstrates the use of IOM drivers with SIOs
and tasks by
* using the DIO class driver with a user defined device mini-
driver
* called "codec" and a class driver DIO instance called
"dio_codec". This is
* the loopback application where audio is read from an input
SIO, then sent
* back via an output SIO.

* The following objects need to be created in the DSP/BIOS


* configuration for this application:
*
* * A UDEV object, which links in a user device driver. In this
* case the UDEV is a codec based IOM device driver.

Digital Shark Technology Page 32


TMS320C6713 Lab Manual

* * A DIO object, which links the UDEV object.


* * A TSK object, with the function to run set to the function
echo
* defined in this file.
* * A LOG named trace for debug and status output.
*/

#include <std.h>

#include <log.h>
#include <sys.h>
#include <mem.h>
#include <sio.h>

#ifdef _6x_
extern far LOG_Obj trace;

/*
* Buffers placed in external memory are aligned on a 128 bytes
boundary.

Digital Shark Technology Page 33


TMS320C6713 Lab Manual

* In addition, the buffer should be of a size multiple of 128


bytes for
* the cache work optimally on the C6x.
*/
#define BUFLEN 128 /* number of samples in the frame */
#define BUFALIGN 128 /* alignment of buffer to allow use of
L2 cache */
#else
extern LOG_Obj trace;
#define BUFLEN 128 /* number of samples in the frame */
#define BUFALIGN 1
#endif

#define BUFSIZE (BUFLEN * sizeof(MdUns))

/* inStream and outStream are SIO handles created in main */


SIO_Handle inStream, outStream;

/* Function prototype */
static Void createStreams();
static Void prime();

Digital Shark Technology Page 34


TMS320C6713 Lab Manual

/*
* ======== main ========
*/
Void main()
{
LOG_printf(&trace, "tsk_audio started");
}

/*
* ======== createStreams ========
*/
static Void createStreams()
{
SIO_Attrs attrs;

/* align the buffer to allow it to be used with L2 cache */


attrs = SIO_ATTRS;
attrs.align = BUFALIGN;
attrs.model = SIO_ISSUERECLAIM;

Digital Shark Technology Page 35


TMS320C6713 Lab Manual

/* open the I/O streams */


inStream = SIO_create("/dioCodec", SIO_INPUT, BUFSIZE,
&attrs);
if (inStream == NULL) {
SYS_abort("Create input stream FAILED.");
}

outStream = SIO_create("/dioCodec", SIO_OUTPUT, BUFSIZE,


&attrs);
if (outStream == NULL) {
SYS_abort("Create output stream FAILED.");
}
}

/*
* ======== prime ========
*/
static Void prime()
{
Ptr buf0, buf1, buf2, buf3;

Digital Shark Technology Page 36


TMS320C6713 Lab Manual

LOG_printf(&trace, "Allocate buffers started");

/* Allocate buffers for the SIO buffer exchanges */


buf0 = (Ptr)MEM_calloc(0, BUFSIZE, BUFALIGN);
buf1 = (Ptr)MEM_calloc(0, BUFSIZE, BUFALIGN);
buf2 = (Ptr)MEM_calloc(0, BUFSIZE, BUFALIGN);
buf3 = (Ptr)MEM_calloc(0, BUFSIZE, BUFALIGN);
if (buf0 == NULL || buf1 == NULL || buf2 == NULL || buf3 ==
NULL) {
SYS_abort("MEM_calloc failed.");
}

/* Issue the first & second empty buffers to the input stream
*/
if (SIO_issue(inStream, buf0, SIO_bufsize(inStream), NULL) !=
SYS_OK) {
SYS_abort("Error issuing buffer to the input stream");
}
if (SIO_issue(inStream, buf1, SIO_bufsize(inStream), NULL) !=
SYS_OK) {

Digital Shark Technology Page 37


TMS320C6713 Lab Manual

SYS_abort("Error issuing buffer to the input stream");


}

/* Issue the first & second empty buffers to the output


stream */
if (SIO_issue(outStream, buf2, SIO_bufsize(outStream), NULL)
!= SYS_OK) {
SYS_abort("Error issuing buffer to the output stream");
}
if (SIO_issue(outStream, buf3, SIO_bufsize(outStream), NULL)
!= SYS_OK) {
SYS_abort("Error issuing buffer to the output stream");
}
}

/*
* ======== echo ========
* This function copies from the input SIO to the output SIO.
You could
* easily replace the copy function with a signal processing
algorithm.
*/

Digital Shark Technology Page 38


TMS320C6713 Lab Manual

Void echo()
{
Int i;
Int nmadus; /* number of minimal addressable units */
MdUns *inbuf, *outbuf;

/* Call createStream function to create I/O streams */


createStreams();

/* Call prime function to do priming */


prime();

/* Loop forever looping back buffers */


for (;;) {
/* Reclaim full buffer from the input stream */
if ((nmadus = SIO_reclaim(inStream, (Ptr *)&inbuf, NULL)) <
0) {
SYS_abort("Error reclaiming full buffer from the input
stream");
}

Digital Shark Technology Page 39


TMS320C6713 Lab Manual

/* Reclaim empty buffer from the output stream to be


reused */
if (SIO_reclaim(outStream, (Ptr *)&outbuf, NULL) < 0) {
SYS_abort("Error reclaiming empty buffer from the
output stream");
}

/* Do the data move. */


for (i = 0; i < (nmadus / sizeof(short)); i++) {
outbuf[i] = inbuf[i];
}

/* Issue full buffer to the output stream */


if (SIO_issue(outStream, outbuf, nmadus, NULL) != SYS_OK)
{
SYS_abort("Error issuing full buffer to the output
stream");
}

/* Issue an empty buffer to the input stream */


if (SIO_issue(inStream, inbuf, SIO_bufsize(inStream), NULL)
!= SYS_OK) {

Digital Shark Technology Page 40


TMS320C6713 Lab Manual

SYS_abort("Error issuing empty buffer to the input


stream");
}
}
}

/*
* ======== prd10secs ========
* prd10secs is configured to be called every 10 seconds
*/
Void prd10secs()
{
static Int seconds = 0;
static Int minutes = 0;
static Int hours = 0;

seconds += 10;

if (seconds == 60) {
seconds = 0;

Digital Shark Technology Page 41


TMS320C6713 Lab Manual

minutes++;
if (minutes == 60) {
minutes = 0;
hours++;
}
LOG_printf(&trace, "%d hours and %d minutes", hours,
minutes);
}
else {
LOG_printf(&trace, "%d seconds", seconds);
}
}

Build, Connect the board and Run the program.


Results
Connect Speaker to Line OUT to hear audio loopback from line
in

Digital Shark Technology Page 42


TMS320C6713 Lab Manual

8. Voice Scrambling Using Filtering and Modulation


//Scram16k.c Voice scrambler/de-scrambler program
#include "dsk6713_aic23.h" //codec-dsk support file
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
#include "sine160.h" //sine data values
#include "LP114.cof" //filter coefficient file
short filtmodfilt(short data);
short filter(short inp,short *dly);
short sinemod(short input);
static short filter1[N],filter2[N];
short input, output;

void main()
{
short i;

comm_poll(); //init DSK using polling


for (i=0; i< N; i++)
{
filter1[i] = 0; //init 1st filter buffer

Digital Shark Technology Page 43


TMS320C6713 Lab Manual

filter2[i] = 0; //init 2nd filter buffer


}
while(1)
{
input=input_sample(); //input new sample data
filtmodfilt(input); //process sample twice(upsample)
output=filtmodfilt(input); //and throw away 1st result
output_sample(output); //then output
}
}

short filtmodfilt(short data) //filtering & modulating


{
data = filter(data,filter1); //newest in ->1st filter
data = sinemod(data); //modulate with 1st filter out
data = filter(data,filter2); //2nd LP filter
return data;
}

short filter(short inp,short *dly) //implements FIR

Digital Shark Technology Page 44


TMS320C6713 Lab Manual

{
short i;
int yn;

dly[N-1] = inp; //newest sample @bottom buffer


yn = dly[0] * h[N-1]; //y(0)=x(n-(N-1))*h(N-1)
for (i = 1; i < N; i++) //loop for the rest
{
yn += dly[i] * h[N-(i+1)]; //y(n)=x[n-(N-1-i)]*h[N-1-i]
dly[i-1] = dly[i]; //data up to update delays
}
yn = (yn >>15); //filter's output
return yn; //return y(n) at time n
}

short sinemod(short input) //sine generation/modulation


{
static short i=0;

input=(input*sine160[i++])>>11; //(input)*(sine data)

Digital Shark Technology Page 45


TMS320C6713 Lab Manual

if(i>= NSINE) i = 0; //if end of sine table


return input; //return modulated signal
}

Results
On successful execution of program can hear scrambled voice
at lineout.

Digital Shark Technology Page 46


TMS320C6713 Lab Manual

9. FIR filter.
//Fir3LP.c FIR using 3 low-pass coefficients with three different
BW
#include "lp600.cof" //coeff file LP @ 600 Hz
#include "lp1500.cof" //coeff file LP @ 1500 Hz
#include "lp3000.cof" //coeff file LP @ 3000 Hz
#include "dsk6713_aic23.h" //codec-dsk support file
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
short LP_number = 2; //start with 1st LP filter
int yn = 0; //initialize filter's
output
short dly[N]; //delay samples
short h[3][N]; //filter characteristics 3xN

interrupt void c_int11() //ISR


{
short i;

dly[0] = input_sample(); //newest input @ top of


buffer
yn = 0; //initialize filter output

Digital Shark Technology Page 47


TMS320C6713 Lab Manual

for (i = 0; i< N; i++)


yn +=(h[LP_number][i]*dly[i]);//y(n) += h(LP#,i)*x(n-i)
for (i = N-1; i > 0; i--) //starting @ bottom of buffer
dly[i] = dly[i-1]; //update delays with data move
output_sample(yn >> 15); //output filter
return; //return from
interrupt
}

void main()
{
short i;
for (i=0; i<N; i++)
{
dly[i] = 0; //init buffer
h[0][i] = hlp600[i]; //start addr of LP600 coeff
h[1][i] = hlp1500[i]; //start addr of LP1500
coeff
h[2][i] = hlp3000[i]; //start addr of LP3000
coeff
}

Digital Shark Technology Page 48


TMS320C6713 Lab Manual

comm_intr(); //init DSK, codec, McBSP


while(1); //infinite loop
}
Results
On successful execution of program can hear filter sound at
lineout.

Digital Shark Technology Page 49


TMS320C6713 Lab Manual

10.IIR Filter.
//IIR.c IIR filter using cascaded Direct Form II
//Coefficients a's and b's correspond to b's and a's from
MATLAB

#include "DSK6713_AIC23.h" //codec-DSK support file


Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
#include "bs1750.cof" //BS @ 1750 Hz coefficient file
short dly[stages][2] = {0}; //delay samples per stage

interrupt void c_int11() //ISR


{
short i, input;
int un, yn;

input = input_sample(); //input to 1st stage


for (i = 0; i < stages; i++) //repeat for each stage
{
un=input-((b[i][0]*dly[i][0])>>15) - ((b[i][1]*dly[i][1])>>15);

Digital Shark Technology Page 50


TMS320C6713 Lab Manual

yn=((a[i][0]*un)>>15)+((a[i][1]*dly[i][0])>>15)+((a[i][2]*dly[i][1]
)>>15);

dly[i][1] = dly[i][0]; //update delays


dly[i][0] = un; //update delays
input = yn; //intermediate output->input to next
stage
}
output_sample((short)yn); //output final result for time n
return; //return from ISR
}

void main()
{
comm_intr(); //init DSK, codec, McBSP
while(1); //infinite loop
}
Results
On successful execution of program can hear filter sound at
lineout.

Digital Shark Technology Page 51

You might also like