## EC2306 DIGITAL SIGNAL PROCESSING LAB SYLLABUS

EC2306 DIGITAL SIGNAL PROCESSING LAB L T P C 0 0 3 2 USING **TMS320C5X**/**TMS320C67XX**/ **ADSP218X/219X**/** BS531/532/561**

☞Study of various addressing modes of DSP using simple programming examples

☞**Implementation of Linear and Circular Convolution**

☞**Sampling of input signal and display**

☞**Waveform generation**

☞**Implementation of FIR filter**

## USING MATLAB

☞Generation of Signals

☞**Linear and circular convolution** of two sequences

☞Sampling and effect of aliasing

☞Design of FIR filters

☞Design of IIR filters

☞Calculation of FFT of a signal

☞Decimation by polyphase decomposition.

## STUDY OF VARIOUS ADDRESSING MODES OF DSP USING SIMPLE PROGRAMMING EXAMPLES

## Aim

To Study the various addressing mode of **TMS320C6745** DSP processor.

## Addressing Modes

The addressing modes on the **DSP** are linear, circular using BK0, and circular using BK1. The addressing mode is specified by the addressing mode register (AMR).

All registers can perform linear addressing. Only eight registers can perform circular addressing: A4-A7 are used by the .D1 unit, and B4-B7 are used by the .D2 unit. No other units can perform circular addressing. **LDB(U)/LDH(U)/LDW, STB/STH/STW, LDNDW, LDNW, STNDW, STNW, LDDW, STDW, ADDAB/ADDAH/ADDAW/ADDAD, and SUBAB/SUBAH/SUBAW** instructions all use AMR to determine what type of address calculations are performed for these registers. There is no **SUBAD** instruction.

## Addressing Mode Register (AMR)

For each of the eight registers (A4-A7, B4-B7) that can perform linear or circular addressing, the **addressing mode register** (**AMR**) specifies the addressing mode. A 2-bit field for each register selects the address modification mode: linear (the default) or circular mode. With circular addressing, the field also specifies which BK (block size) field to use for a circular buffer. The mode select & block size fields are choose by writing values to AMR. The register details about AMR is availble at **TMS320C674x DSP** CPU and Instruction Set Reference Guide.

## Linear Addressing Mode

## LD and ST Instructions

For load and store instructions, linear mode simply shifts the offsetR/cst operand to the left by 3, 2, 1, or 0 for doubleword, word, halfword, or byte access, respectively; and then performs an add or a subtract to baseR (depending on the operation specified). The LDNDW and STNDW instructions also support nonscaled offsets. In nonscaled mode, the offsetR/cst is not shifted before adding or subtracting from the baseR.

For the preincrement, predecrement, positive offset, and negative offset address generation options, the result of the calculation is the address to be accessed in memory. For postincrement or postdecrement addressing, the value of baseR before the addition or subtraction is the address to be accessed from memory.

## ADDA and SUBA Instructions

For integer addition and subtraction instructions, linear mode simply shifts the src1/cst operand to the left by 3, 2, 1, or 0 for doubleword, word, halfword, or byte data sizes, respectively, and then performs the add or subtract specified.

## Circular Addressing Mode

The BK0 and BK1 fields in AMR specify the block sizes for circular addressing

## LD and ST Instructions

As with linear address arithmetic, offsetR/cst is shifted left by 3, 2, 1, or 0 according to the data size, and is then added to or subtracted from baseR to produce the final address. Circular addressing modifies this slightly by only allowing bits N through 0 of the result to be updated, leaving bits 31 through N + 1 unchanged after address arithmetic.

The resulting address is bounded to 2(N + 1) range, regardless of the size of the offsetR/cst.

The circular buffer size in AMR is not scaled; for example, a block-size of 8 is 8 bytes, not 8 times the data size (byte, halfword, word). So, to perform circular addressing on an array of 8 words, a size of 32 should be specified, or N = 4. **Example** shows an LDW performed with register A4 in circular mode and BK0 = 4, so the buffer size is 32 bytes, 16 halfwords, or 8 words. The value in AMR for this example is 0004 0001h

## ADDA and SUBA Instructions

As with linear address arithmetic, offsetR/cst is shifted left by 3, 2, 1, or 0 according to the data size, and is then added to or subtracted from baseR to produce the final address. Circular addressing modifies this slightly by only allowing bits N through 0 of the result to be updated, leaving bits 31 through N + 1 unchanged after address arithmetic. The resulting address is bounded to 2(N + 1) range, regardless of the size of the offsetR/cst.

The circular buffer size in AMR is not scaled; for example, a block size of 8 is 8 bytes, not 8 times the data size (byte, halfword, word). So, to perform circular addressing on an array of 8 words, a size of 32 should be specified, or N = 4.

**Example** shows an ADDAH performed with register A4 in circular mode and BK0 = 4, so the buffer size is 32 bytes, 16 halfwords, or 8 words. The value in AMR for this example is 0004 0001h.

## Result

Thus, the various addressing mode of** DSP processor TMS320C6745** was studied.

## CONVOLUTION

## LINEAR CONVOLUTION

## Aim

To perform the **Linear Convolution** of two given discrete sequence in **TMS320C6745 KIT**

## Requirements

☞CCS v4

☞USB Cable

☞5V Adapter

## Theory

Convolution is a formal mathematical operation, just as multiplication, addition, and integration. Addition takes two numbers and produces a third number, while convolution takes two signals and produces a third signal. Convolution is used in the mathematics of many fields, such as probability and statistics. In linear systems, convolution is used to describe the relationship between three signals of interest: the input signal, the impulse response, and the output signal.

If the input and impulse response of a system are x[n] and h[n] respectively, the convolution is given by the expression,

x[n] * h[n] = ∑ x[k] h[n-k]

Where k ranges between -∞ and ∞

If,

x(n) is a M- point sequence

h(n) is a N – point sequence

then, y(n) is a (M+N-1) – point sequence.

In this equation, x(k), h(n-k) and y(n) represent the input to and output from the system at time n. Here we could see that one of the inputs is shifted in time by a value every time it is multiplied with the other input signal. **Linear Convolution** is quite often used as a method of implementing filters of various types.

## Procedure

1. Open Code Composer Studio v4.

2. In Workspace Launcher.

☞**BROWSE →** Select the project location and make one new folder, **MAKE NEW FOLDER →**Type the Workspace name, **OK → OK**.

3. **FILE → NEW → CCS PROJECT**

☞Project name: Type your project name.

☞Tick use default location. →NEXT

☞ Project type: C6000.

☞Tick Debug and Release. →NEXT → NEXT.

☞ Output type: Executable.

☞ Device Variant: generic C67XX Device.

☞ Device Endianness : little

☞ Code Generation Tools: TI v6.1.12.

☞ Run time support library: automatic.

☞ Target content: none. → FINISH

4. **FILE → NEW → SOURCE FILE**

☞Source file: Type your projectname.c(.c extension is must).

☞Type the program.

☞**FILE → SAVE.**

5. **Paste the following board library files in workspace location.**

☞Common folder (contains header files)

☞Gel folder (contains gel file)

☞Library folder(contains library files)

6. **Paste the Linker file in the project location.(linker file is available in cd)**

**Note:** Those folders and linker file are availble at cd.

7. **PROJECT → PROPERTIES → C/C++ BUILD → BASIC OPTION**

☞Target processor version(–silicon version, -mv) : 6400+ **→ OK.**

☞IN C/C++ BUILD, → INCLUDE OPTIONS (Add dir to #include search path(–include_path,-I)) select this add icon and add the following three path by indivdually – → “${Diag}../../common/header” – → “${XDAIS_CG_ROOT}/packages/ti/xdais” – → “${C6000_CSL_CG_ROOT}/include”

8. **FILE → NEW → TARGET CONFIGURATION FILE**

☞file name: projectname. ccxml (.ccxml extension is must)

☞Connection: Texas Instrument XDS100 v1 USB Emulator.

☞Device: **TMS320C6745**. **→ SAVE → TARTGET CONFIGURATION →C674X_0 →BROWSE**, browse the workspace location, open the gel folder and select the GEL file. **→ OPEN →SAVE.**

9. In C/C++ Project window, Right click the project **→REBUILD PROJECT.**

10. Connections :

☞Connect the usb cable, PC to KIT.

☞Connect the 5v adapter.

☞Power on the kit.

11. **TARGET → DEBUG ACTIVE PROJECT.**

12. VIEW → MEMORY.

13. In right side, memory window will open. Type the adrress and give the input at particular location.

Give the input as follow:

X(n) h(n) 0xC0001000 – 00000001 0xC0001030 – 00000001 0xC0001004 – 00000001 0xC0001034 – 00000001 0xC0001008 – 00000001 0xC0001038 – 00000001 0xC000100C – 00000001 0xC000103C – 00000001

14. **TARGET → RUN.**

15. **TARGET → HALT.**

See the Output at Particular location:

Example :

0xC0001050 – 00000001 0xC0001054 – 00000002 0xC0001058 - 00000003 0xC000105C - 00000004 0xC0001060 - 00000003 0xC0001064 - 00000002 0xC0001068 – 00000001

## Program

```
#include
#define xn 4
#define hn 4
void main()
{
int *x,*h,*y,i,n,k;
x = (int *)0xc0001000;
h = (int *)0xc0001030;
y = (int *)0xc0001050;
for(i=0;i<(xn+hn-1);i++)
{
y[i]=0;
x[xn+i]=0;
h[hn+i]=0;
}
for(n=0;n<(xn+hn-1);n++)
{
for(k=0;k<=n;k++)
y[n] = (y[n]) + ((x[k])*(h[n-k]));
}
while(1);
}
```

## Result

Thus, the **Linear Convolution** of two given discrete sequence has performed and the result is stored at memory location(0xC0001050).

## CIRCULAR CONVOLUTION

## Aim

To perform the **Circular Convolution** of two given discrete sequence in **TMS320C6745 KIT**.

## Requirements

☞CCS v4

☞USB Cable

☞5V Adapter

## Theory

The **circular convolution**, also known as cyclic convolution. A convolution operation that contains a circular shift is called circular convolution.** Circular convolution** of two sequences x1[n] and x2[n] is given by

x1[n]*x_{2[n] = ∑k x1[k] x2((n-k))N, 0= n =N-1}

where k ranges between 0 and N-1

One of the methods to find circular convolution….

In **circular convolution** the length of the output sequence will be equal to length of the input sequence ie. length(y)=length(x) So first perform linear convolution using any of the methods u find easier.

If m is the length of ‘x’ and n is the length of the ‘h’ then length of ‘yl’ from linear conv is m+n-1.

Since length of output from circular conv is m, we will bring the last n-1 terms from ‘yl’ and add them to first n-1 terms.

So the obtained output is circularly convoluted output.

For eg. if x= 1, 2, 3, 4 and h= 2,3,1

lin conv op ie. yl= 2,7,13,19,15,4

bring last two (n-1) terms to first two terms

so circularly convluted op is yc= 17, 11,13,19

## Procedure

1. Open Code Composer Studio v4 .

2. In WorkSpace Launcher.

☞**BROWSE **Select the project location and make one new folder, **MAKE NEW FOLDER →Type** the Workspace name, **OK → OK.**

3. **FILE → NEW → CCS PROJECT**

☞Project name: Type your project name.

☞Tick use default location. **&rar;NEXT**

☞Project type: C6000.

☞Tick Debug And Release. **→NEXT → NEXT.**

☞Output type: Executable.

☞Device Variant : generic C67XX Device.

☞Device Endianness : little

☞Code Generation Tools: TI v6.1.12.

☞Run time support library: automatic.

☞Target content: none. → FINISH

4.**FILE → NEW → SOURCE FILE**

☞Source file: Type your projectname.c( .c extension is must ).

☞Type the program.

☞**FILE → SAVE.**

5. Paste the following board library files in workspace location.

☞Common folder (contains header files)

☞Gel folder (contains gel file)

☞Library folder(contains library files)

6. Paste the Linker file in the project location.(linker file is available in cd)

**Note:** Those folders and linker file are availble at cd.

7.** PROJECT → PROPERTIES → C/C++ BUILD → BASIC OPTION**

☞Target processor version(–silicon version, -mv) : 6400+ → OK.

☞IN C/C++ BUILD, → INCLUDE OPTIONS (Add dir to #include search path(–include_path,-I)) select this add icon and add the following three path by indivdually **→** “${Diag}../../common/header” **→** “${XDAIS_CG_ROOT}/packages/ti/xdais” **→** “${C6000_CSL_CG_ROOT}/include”

8. **FILE → NEW → TARGET CONFIGURATION FILE**

☞file name: projectname. ccxml (.ccxml extension is must)

☞Connection: Texas Instrument XDS100 v1 USB Emulator.

☞Device: **TMS320C6745**. **→** SAVE **→** TARTGET CONFIGURATION → C674X_0 → BROWSE, browse the workspace location, open the gel folder and select the GEL file. **→ OPEN → SAVE.**

9. In C/C++ Project window, Right click the project **→REBUILD PROJECT.**

10. Connections :

☞Connect the usb cable, PC to **TMS320C6745 KIT**.

☞Connect the 5v adapter.

☞Power on the kit.

11. **TARGET → DEBUG ACTIVE PROJECT.**

12. **VIEW → MEMORY**

13. In right side, memory window will open. Type the adrress and give the input at particular location.

Give the input as follow:

X(n) h(n) 0xC0001000 – 00000001 0xC0001030 – 00000001 0xC0001004 – 00000001 0xC0001034 – 00000001 0xC0001008 – 00000001 0xC0001038 – 00000001 0xC000100C – 00000001 0xC000103C – 00000001

14. **TARGET → RUN.**

15. **TARGET → HALT.**

See the Output at Particular location:

Example :

0xC0001050 – 00000004 0xC0001054 – 00000004 0xC0001058 - 00000004 0xC000105C - 00000004

## Program

```
#include
int rot(int *x);
void main()
{
int *in1,*in2,*out,*temp,i,sum=0,j;
in1 = (int *)0xc0001000;
in2 = (int *)0xc0001030;
out = (int *)0xc0001050;
temp = (int *)0xc0002000;
for(i=0;i<4;i++)
{
if(i == 1)
temp[i+2] = in1[i];
else if(i == 3)
temp[i-2] = in1[i];
else
temp[i] = in1[i];
}
for(i=0;i<4;i++)
{
sum = 0;
for(j=0;j<4;j++)
{
sum+=(in2[j] * temp[j]);
}
out[i] = sum;
rot(temp);
}
while(1);
}
rot(int *x)
{
int t;
t = x[0];
x[0] = x[3];
x[3] = x[2];
x[2] = x[1];
x[1] = t;
}
```

## Result

Thus, the **Circular Convolution** of two given discrete sequence has performed and the result is stored at memory location(0xC0001050).

## SAMPLING OF INPUT AND DISPLAY

## Aim

To Sample the input sinewave waveform using **TMS320C6745 DSP KIT**.

## Requirements

☞CCS v4

☞USB Cable

☞5V Adapter

## Theory

**Sampling **is the process of converting a **signal** (for example, a function of continuous time or space) into a numeric sequence (a function of discrete time or space) at the regular time interval. The sampling frequency should be greater than or equal to 2*input frequency, and the frequency should be bounded.

i,e., f_{s} = 2 * finput

where f_{s}= sampling frequency. To avoid alias, always our input frequency is lesser than the half the sampling frequency. The input Sinusoidal signal is sampled through ADC (MCP3202) at regular interval. Then the generated sample is stored to to display in CCS Graph Tool.

## Procedure

1. Open Code Composer Studio v4 .

2. In WorkSpace Launcher.

☞**BROWSE →** Select the project location and make one new folder, **MAKE NEW FOLDER →**Type the Workspace name, **OK → OK.**

3. **FILE → NEW → CCS PROJECT**

☞Project name: Type your project name.

☞Tick use default location. **→NEXT**

☞Project type: C6000.

☞Tick Debug And Release. **→NEXT → NEXT.**

☞Output type: Executable.

☞Device Variant : generic C67XX Device.

☞Device Endianness : little

☞Code Generation Tools: TI v6.1.12.

☞Run time support library: automatic.

☞Target content: none. → FINISH

4.**FILE → NEW → SOURCE FILE**

☞Source file: Type your projectname.c( .c extension is must ).

☞Type the program.

☞**FILE → SAVE.**

5. Paste the following board library files in workspace location.

☞Common folder (contains header files)

☞Gel folder (contains gel file)

☞Library folder(contains library files)

6. Paste the Linker file and spiadc.h in the project location.(linker file is available in cd)

**Note:** Those folders and linker file are availble at cd.

7. **PROJECT → PROPERTIES → C/C++ BUILD → BASIC OPTION**

☞Target processor version(–silicon version, -mv) : 6400+ **OK.**

☞IN C/C++ BUILD, **→** INCLUDE OPTIONS (Add dir to #include search path(–include_path,-I)) select this add icon image< and add the following three path by indivdually **→** “${Diag}../../common/header” **→** “${XDAIS_CG_ROOT}/packages/ti/xdais” **→** “${C6000_CSL_CG_ROOT}/include”

8. **FILE → NEW → TARGET CONFIGURATION FILE**

☞file name: projectname. ccxml (.ccxml extension is must)

☞Connection: Texas Instrument XDS100 v1 USB Emulator.

☞Device: **TMS320C6745**. **→** SAVE **→** TARTGET CONFIGURATION → C674X_0 → BROWSE, browse the workspace location, open the gel folder and select the GEL file. **→ OPEN →SAVE.**

9. In C/C++ Project window, Right click the project **→REBUILD PROJECT.**

10. Connections :

☞Connect the usb cable, PC to **TMS320C6745 KIT**.

☞Connect the 5v adapter.

☞Power on the kit.

11. **TARGET → DEBUG ACTIVE PROJECT.**

**Note: **Connect the Function generator probe positive terminal to Adc input pin and negative terminal to ground. Set the frequency as 1Khz & Amplitude as 3V.

12. **TARGET → RUN.**(wait few seconds read samples)

13. **TARGET → HALT.**

14. **TOOLS → GRAPH → SINGLE TIME**

☞Acquirstion buffer size : 500

☞Index increment : 1

☞Start address : adc_value.

☞Display data size : 500 **→ Ok.**

## Program

```
#include "stdio.h"
#include "c6745.h"
#include "spiadc.h"
signed int adc_value[1000];
void main( void )
{
static Uint8 spiadcbuf[3];
unsigned int j;
short *out,i=0;
C6745_init( );
out = (short *)0xc0000000;
spiadc_init();
for(i=0;i<500;i++)
{
spiadcbuf[0] = 0x01; // setup command
spiadcbuf[1] = 0xBF;
spiadcbuf[2] = 0x00;
spiadc_cycle(spiadcbuf, 3); // Execute spiadc read cycle
adc_value[i] = ((spiadcbuf[1]&0x0f) << 8)| spiadcbuf[2];
//for(j=0;j<100000;j++);
}
printf("ALL PROCESSED");
while(1);
}
```

## Result

Thus, the Sampling of input sine waveform was sampled and Displayed the sampled signal in Graph.

## WAVEFORM GENERATION

## SINE WAVEFORM GENERATION

## Aim

To Generate a sinewave form using **TMS320C6745 DSP KIT**.

## Requirements

☞CCS v4

☞USB Cable

☞5V Adapter

## Theory

The simplest method to generate Sine wave is to use Trignometric Sin function. The Sin function will generate the samples from our specific parameter like sampling frequency, number of samples, input frequency. In this project, generating the correct sample is important. The library function “sin()” does all of the work.

Its most basic form as a function of time (t) is:

*y(t)*=A.sin(*ωt + φ*)

where:

A, the amplitude, is the peak deviation of the function from its center position.

ωthe angular frequency, specifies how many oscillations occur in a unit time interval, in radians per second

φthe phase, specifies where in its cycle the oscillation begins at t = 0.

When the phase is non-zero, the entire waveform appears to be shifted in time by the amount f/? seconds. A negative value represents a delay, and a positive value represents an advance.

## Procedure

1. Open Code Composer Studio v4 .

2. In WorkSpace Launcher.

☞**BROWSE →** Select the project location and make one new folder, **MAKE NEW FOLDER →Type** the Workspace name, **OK → OK.**

3. **FILE → NEW → CCS PROJECT**

☞Project name: Type your project name.

☞Tick use default location. **→NEXT**

☞Project type: C6000.

☞Tick Debug And Release. **→NEXT → NEXT.**

☞Output type: Executable.

☞Device Variant : generic C67XX Device.

☞Device Endianness : little

☞Code Generation Tools: TI v6.1.12.

☞Run time support library: automatic.

☞Target content: none. **→FINISH**

4. **FILE → NEW → SOURCE FILE**

☞Source file: Type your projectname.c( .c extension is must ).

☞Type the program.

☞**FILE → SAVE.**

5. Paste the following board library files in workspace location.

☞Common folder (contains header files)

☞Gel folder (contains gel file)

☞Library folder(contains library files)

6. Paste the Linker file in the project location.(linker file is available in cd)

**Note:** Those folders and linker file are availble at cd.

7. **PROJECT → PROPERTIES → C/C++ BUILD → BASIC OPTION**

☞Target processor version(–silicon version, -mv) : 6400+ **OK.**

☞IN C/C++ BUILD, → INCLUDE OPTIONS (Add dir to #include search path(–include_path,-I)) select this add icon and add the following three path by indivdually **→** “${Diag}../../common/header” **→** “${XDAIS_CG_ROOT}/packages/ti/xdais” **→** “${C6000_CSL_CG_ROOT}/include”

8. **FILE → NEW → TARGET CONFIGURATION FILE**

☞file name: projectname. ccxml (.ccxml extension is must)

☞Connection: Texas Instrument XDS100 v1 USB Emulator.

☞Device: **TMS320C6745**. **→ SAVE → TARTGET CONFIGURATION →C674X_0 →BROWSE,→ browse the workspace location, open the gel folder and select the GEL file. OPEN → SAVE.**

9. In C/C++ Project window, Right click the project **→REBUILD PROJECT.**

10. Connections

☞Connect the usb cable, PC to **TMS320C6745 KIT**.

☞Connect the 5v adapter.

☞Power on the kit.

11. **TARGET → DEBUG ACTIVE PROJECT.**

12. **TARGET → RUN.**(wait to generate samples)

13. **TARGET → HALT.**

14. **TOOLS → GRAPH → SINGLE TIME**

☞Acquirstion buffer size : 256

☞Index increment : 1

☞Start address : 0xC0000000.

☞Display data size : 256 **→ Ok.**

## Program

```
#include
#define PI 3.14
void main()
{
const float sampf = 1024000.0;// Sampling frquency is fixed
const int inpf = 4000; // change the input frquency from 1khz to 8khz(1000 to 8000)
float sampt;
double teta;
short value,*sinout;
int i,count,nsamp,value1;
sinout = (short *)0xc0000000;
sampt = 1/sampf;
nsamp = sampf/inpf;
printf("\n Sampling Frequency is : %f",sampf);
printf("\n Sampling Time is :%f",sampt);
printf("\n Input Frequency is : %d",inpf);
printf("\n The number of Sample is : %d",nsamp);
for(i=0;i<400;i++)
*(sinout+i)=0;
for(count=0;count<nsamp;count++)
{
teta = (2 * PI * inpf * sampt * count);
printf("\nteta = %lf",teta);
value = sin(teta)*1024;
printf("\t sin %lf Value is : %d",teta,value);
value1 = value&0x0000FFFF;
*sinout++ = value1;
}
}
```

## Result

Thus, the **Sine waveform generation** was generated and the sine samples is stored at memory location(0xc0000000).

## IMPLEMENTATION OF FIR FILTER

## FIR LOW PASS FILTER

## Aim

To Implement the **FIR Low pass filter using TMS320C6745 KIT**

## Requirements

☞CCS v4

☞USB Cable

☞5V Adapter

## Theory

In signal processing, a **finite impulse response (FIR)** filter is a filter whose impulse response (or response to any finite length input) is of finite duration, because it settles to zero in finite time. This is in contrast to** infinite impulse response** (**IIR**) filters, which may have internal feedback and may continue to respond indefinitely (usually decaying).

The impulse response of an Nth-order discrete-time FIR filter (i.e., with a Kronecker delta impulse input) lasts for N + 1 samples, and then settles to zero.

The output y of a linear time invariant system is determined by convolving its input signal x with its impulse response *b.*

For a discrete time** FIR filter**, the output is a weighted sum of the current and a finite number of previous values of the input. The operation is described by the following equation, which defines the output sequence y[n] in terms of its input sequence x[n]

where:

*x[n]*is the input signal,

*y[n]*is the output signal,

*b _{iare the filter coefficients, also known as tap weights, that make up the impulse response,}*

Nis the filter order; an th-order filter has (N + 1) terms on the right-hand side. The *x[n-i]* in these terms are commonly referred to as taps, based on the structure of a tapped delay line that in many implementations or block diagrams provides the delayed inputs to the multiplication operations. One may speak of a 5th order/6-tap filter, for instance.

## Procedure

1. Open Code Composer Studio v4 .

2. In WorkSpace Launcher.

☞**BROWSE →** Select the project location and make one new folder, **MAKE NEW FOLDER →Type** the Workspace name, **OK → OK.**

3. **FILE → NEW → CCS PROJECT**

☞Project name: Type your project name.

☞Tick use default location. **→NEXT**

☞Project type: C6000.

☞Tick Debug And Release. **→NEXT → NEXT.**

☞Output type: Executable.

☞Device Variant : generic – **TMS320C6745**.

☞Device Endianness : little

☞Code Generation Tools: TI v6.1.12.

☞Run time support library: automatic.

☞Target content: none. → FINISH

4.**FILE → NEW → SOURCE FILE**

☞Source file: Type your projectname.c( .c extension is must ).

☞Type the program.

☞**FILE → SAVE.**

5. Paste the following board library files in workspace location.

☞Common folder (contains header files)

☞Gel folder (contains gel file)

☞Library folder(contains library files)

6. Paste the Linker file in the project location.(linker file is available in cd)

**Note:** Those folders and linker file are availble at cd.

7. **PROJECT → PROPERTIES → C/C++ BUILD → BASIC OPTION**

☞Target processor version(–silicon version, -mv) : 6400+ **OK.**

☞IN C/C++ BUILD, → INCLUDE OPTIONS (Add dir to #include search path(–include_path,-I)) select this add icon image< and add the following three path by indivdually **→** “${Diag}../../common/header” **→** “${XDAIS_CG_ROOT}/packages/ti/xdais” **→** “${C6000_CSL_CG_ROOT}/include”

8. **FILE → NEW → TARGET CONFIGURATION FILE**

☞file name: projectname. ccxml (.ccxml extension is must)

☞Connection: Texas Instrument XDS100 v1 USB Emulator.

☞Device: **TMS320C6745**. (Tick the **TMS320C6745**)**→ SAVE → TARTGET CONFIGURATION →C674X_0 →BROWSE,** browse the workspace location, open the gel folder and select the GEL file. **→ OPEN →SAVE.**

9. In C/C++ Project window, Right click the project **→REBUILD PROJECT.**

10. Connections

☞Connect the usb cable, PC to **TMS320C6745 KIT**.

☞Connect the 5v adapter.

☞Power on the kit.

11. **TARGET → DEBUG ACTIVE PROJECT.**

12. **TARGET → RUN.(wait few seconds)**

13. Output is displayed at Console Window.

14. **TARGET → HALT.**

## Program

```
// ideal low pass filter
#include
#include
#define PI 3.14
void main()
{
const int sampf=10000;
const int cutf=1000;
float value,a,b,output;
int nyqf,n,c0;
int *coeff;
coeff = (int *)0xc0001000;
nyqf=sampf/2;
c0=cutf/nyqf;
for(n=-5;n<6;n++)
{
if(n==0)
{
output = 0.5;
}
else
a = (n * PI)/2;
b = n * PI;
value = sin(a);
output = value/b;
printf("\n The Fir Low pass filter coefficient : %f",output);
}
}
```

## FIR HIGH PASS FILTER

## Aim

To Implement the **FIR High pass filter using TMS320C6745 KIT.**

## Requirements

☞CCS v4

☞USB Cable

☞5V Adapter

## Theory

In signal processing, a **finite impulse response (FIR)** filter is a filter whose impulse response (or response to any finite length input) is of finite duration, because it settles to zero in finite time. This is in contrast to** infinite impulse response** (**IIR**) filters, which may have internal feedback and may continue to respond indefinitely (usually decaying).

The impulse response of an Nth-order discrete-time **FIR filter** (i.e., with a Kronecker delta impulse input) lasts for N + 1 samples, and then settles to zero.

The output y of a linear time invariant system is determined by convolving its input signal x with its impulse response *b.*

For a discrete time **FIR filter**, the output is a weighted sum of the current and a finite number of previous values of the input. The operation is described by the following equation, which defines the output sequence y[n] in terms of its input sequence x[n]

where:

*x[n]* is the input signal,

*y[n]* is the output signal,

*bi are the filter coefficients, also known as tap weights, that make up the impulse response,*

N is the filter order; an Nth-order filter has (N + i) terms on the right-hand side. The x[n-i] in these terms are commonly referred to as taps, based on the structure of a tapped delay line that in many implementations or block diagrams provides the delayed inputs to the multiplication operations. One may speak of a 5th order/6-tap filter, for instance.

## Procedure

1. Open Code Composer Studio v4 .

2. In WorkSpace Launcher.

☞**BROWSE →** Select the project location and make one new folder, **MAKE NEW FOLDER →Type** the Workspace name, **OK → OK.**

3. FILE → NEW → CCS PROJECT

☞Project name: Type your project name.

☞Tick use default location. **→NEXT**

☞Project type: C6000.

☞Tick Debug And Release. **→NEXT → NEXT.**

☞Output type: Executable.

☞Device Variant : generic – **TMS320C6745**.

☞Device Endianness : little

☞Code Generation Tools: TI v6.1.12.

☞Run time support library: automatic.

☞Target content: none. **→FINISH**

4.**FILE → NEW → SOURCE FILE**

☞Source file: Type your projectname.c( .c extension is must ).

☞Type the program.

☞**FILE → SAVE.**

5. Paste the following board library files in workspace location.

☞Common folder (contains header files)

☞Gel folder (contains gel file)

☞Library folder(contains library files)

6. Paste the Linker file in the project location.(linker file is available in cd)

**Note:** Those folders and linker file are availble at cd.

7. **PROJECT → PROPERTIES → C/C++ BUILD → BASIC OPTION**

☞Target processor version(–silicon version, -mv) : 6400+ OK.

☞IN C/C++ BUILD, → INCLUDE OPTIONS (Add dir to #include search path(–include_path,-I)) select this add icon and add the following three path by indivdually **→** “${Diag}../../common/header” **→** “${XDAIS_CG_ROOT}/packages/ti/xdais” **→** “${C6000_CSL_CG_ROOT}/include”

8. **FILE → NEW → TARGET CONFIGURATION FILE**

☞file name: projectname. ccxml (.ccxml extension is must)

☞Connection: Texas Instrument XDS100 v1 USB Emulator.

☞Device: **TMS320C6745**. (Tick the **TMS320C6745**)→ SAVE → TARTGET CONFIGURATION → C674X_0 → BROWSE, browse the workspace location, open the gel folder and select the GEL file. → OPEN → SAVE.

9. In C/C++ Project window, Right click the project **→REBUILD PROJECT.**

10. Connections

☞Connect the usb cable, PC to **TMS320C6745 KIT**.

☞Connect the 5v adapter.

☞Power on the kit.

11. **TARGET → DEBUG ACTIVE PROJECT.**

12. **TARGET → RUN.**(wait few seconds)

13. **TARGET → HALT.**(AUTO halt)

14. Output is displayed at Console Window.

## Program

```
// ideal high pass filter coefficients
#include
#include
#define PI 3.14
void main()
{
const int sampf=10000;
const int cutf=1000;
double value,a,b,output,final;
int nyqf,n,c0;
int *coeff;
coeff = (int *)0xc0001000;
nyqf=sampf/2;
c0=cutf/nyqf;
for(n=-5;n<6;n++)
{
if(n==0)
{
output = 0.5;
}
else
a = (n * PI)/2;
b = n * PI;
value = sin(a);
output = value/b;
final = 1 - output;
printf("\n The Fir High pass filter coefficient : %f",final);
}
}
```

## Result

Thus, the** FIR High pass filter** was Implemented and displayed the results in console window.

## GENERATION OF SIGNALS

## CONTINUOUS TIME SIGNAL

## Aim

To Generate a** continuous sinusoidal time signals Using MATLAB.**

## Requirements

Matlab 2007 later

## Procedure

## 1. OPEN MATLAB

## 2. File → New → Script.

☞Type the program in untitled window

## 3. File → Save → type filename.m in matlab workspace path

4. Debug → Run. Wave will displayed at Figure dialog box.

## Program

<

```
% here we generating the sine wave using sin function,
% The input frequency is 1 Khz
% Assuming The Sampling frequency is 5 Mhz
clear all;
Finput = 1000;
Fsampling = 5000000;
Tsampling = 1 / Fsampling;
Nsample = Fsampling/ Finput;
N = 0:5*Nsample-1;
x=sin(2 * pi * Finput * Tsampling * N);
plot(x);
title('Sine Wave Generation');
xlabel('Time -- >');
ylabel('Amplitude-- >');
grid on;
```

## Result

Thus the Signal was generated using MATLAB.

## DISCRETE TIME SIGNAL

## Aim

To Generate a **Discrete time Exponential signals Using MATLAB.**

## Requirements

Matlab 2007 later

## Procedure

## 1. OPEN MATLAB

## 2. File → New → Script.

☞Type the program in untitled window

## 3. File → Save → type filename.m in matlab workspace path

## 4. Debug → Run. Wave will displayed at Figure dialog box.

## Program

```
% here we generating the exponential sequence using function,
% exp(X) returns the exponential for each element of X. exp operates
% element-wise on arrays.
clear all;
a = 0.5;
N = 10;
n = 0:N-1;
x = exp(a * n);
stem(x);
title('Exponential Signal');
xlabel('n value');
ylabel('Amplitude');
```

## Result

Thus the Discrete Time Signal was generated using MATLAB.

## CONVOLUTION

## LINEAR CONVOLUTION

## Aim

To perform a** Linear Convolution Using MATLAB.**

## Requirements

Matlab 2007 later

## Procedure

## 1. OPEN MATLAB

## 2. File → New → Script.

☞Type the program in untitled window

## 3. File → Save → type filename.m in matlab workspace path

## 4. Debug → Run. Wave will displayed at Figure dialog box.

**Note:** Change the input through program in Xn and Hn.

## Program

```
clear all;
Xn = [1,1,1,1];
Hn = [1,1,1,1];
x=length(Xn);
h = length(Hn);
N = x + h - 1;
Yn = conv(Xn,Hn);
subplot(2,2,1);
stem(Xn);
title('Xn');
xlabel('Length of First Input Sequence');
ylabel('Input Value');
subplot(2,2,2);
stem(Hn);
title('Hn');
xlabel('Length of Second Input Sequence');
ylabel('Input Value');
subplot(2,2,3);
stem(Yn);
title('Yn');
xlabel('Length of Output Sequence');
ylabel('Output Value');
```

## Result

Thus the** Linear convolution was performed using MATLAB.**

## CIRCULAR CONVOLUTION

## Aim

To perform a **Circular Convolution Using MATLAB.**

## Requirements

Matlab 2007 later

## Procedure

## 1. OPEN MATLAB

## 2. File → New → Script.

☞Type the program in untitled window

## 3. File → Save → type filename.m in matlab workspace path

## 4. Debug → Run. Wave will displayed at Figure dialog box.

**Note: **Change the input through program in Xn and Hn.

## Program

```
clear all;
Xn = [1,1,1,1];
Hn = [1,1,1,1];
x=length(Xn);
h = length(Hn);
N = max(x,h);
Yn = cconv(Xn,Hn,N);
subplot(2,2,1);
stem(Xn);
title('Xn');
xlabel('Length of First Input Sequence');
ylabel('Input Value');
subplot(2,2,2);
stem(Hn);
title('Hn');
xlabel('Length of Second Input Sequence');
ylabel('Input Value');
subplot(2,2,3);
stem(Yn);
title('Yn');
xlabel('Length of Output Sequence');
ylabel('Output Value');
```

## SAMPLING AND EFFECT OF ALIASING

## Aim

To perform a **Sampling and effect of aliasing Using MATLAB.**

## Requirements

Matlab 2007 later

## Procedure

☞OPEN MATLAB

☞File **→** New **→** Script. – Type the program in untitled window

☞File **→** Save **→** type filename.m in matlab workspace path

☞Debug **→** Run. Wave will displayed at Figure dialog box.

## Program

```
%To study sampling rate conversion using MATLAB
%In this program a 1000Hz signal and a 11000Hz signal are both sampled at
%10000Hz.But they have the same plot.Aliasing will result in a different signal than the one originally expected.
Fs = 10000; % Sampling Frequency
fIn = 1000; % Input Frequency
n = 0 : 100; % No.of Samples
k = 1;
xa = sin(2 * pi * (fIn / Fs) * n);
xb = sin(2 * pi * (fIn + (k * Fs))/ Fs * n);
subplot(2, 1, 1);
plot(n, xa);
title('1 Khz Sine Wave ');
subplot(2, 1, 2);
plot(n, xb);
title('11 Khz Sine Wave ');
```

## Result

Thus the Sampling was performed and studied the aliasing effect using MATLAB.

## DESING OF FIR FILTER

## FIR LOW PASS FILTER

## Aim

To perform a **FIR Low pass filter Using MATLAB.**

## Requirements

Matlab 2007 later

## Procedure

☞OPEN MATLAB

☞File New Script. – Type the program in untitled window

☞File Save type filename.m in matlab workspace path

☞Debug Run. Wave will displayed at Figure dialog box.

## Program

```
%Program – Hamming Window
%Low Pass Filter
clear all;
Fcut = 1000;
Fsamp = 7500;
N = 60; % Order of the filter
d=fdesign.lowpass('N,fc',N,Fcut,Fsamp);
Hd=window(d,'window',@hamming);
fvtool(Hd);
```

## Result

Thus the FIR Low pass was performed and displayed the graph in FVTOOL using MATLAB.

## FIR HIGH PASS FILTER

## Aim

To perform a **FIR High pass filter Using MATLAB.**

## Requirements

Matlab 2007 later

## Procedure

☞OPEN MATLAB

☞File **→** New **→** Script. – Type the program in untitled window

☞File **→** Save **→** type filename.m in matlab workspace path

☞Debug **→** Run. Wave will displayed at Figure dialog box.

## Program

```
%Program – Hamming Window
% High Pass Filter
clear all;
Fcut = 1000;
Fsamp = 7500;
N = 60; % Order of the filter
d= fdesign.highpass('N,fc',N,Fcut,Fsamp)
Hd=window(d,'window',@hamming);
fvtool(Hd);
```

## Result

Thus the **FIR High pass** was performed and displayed the graph in FVTOOL using MATLAB.

## DESING OF IIR FILTER

## IIR LOW PASS FILTER

## Aim

To perform a **IIR Low pass filter Using MATLAB.**

## Requirements

Matlab 2007 later

## Procedure

☞OPEN MATLAB

☞File **→** New **→** Script. – Type the program in untitled window

☞File **→** Save **→** type filename.m in matlab workspace path

☞Debug **→** Run. Wave will displayed at Figure dialog box.

## Program

```
%Program - Butterworth Filter
%Low Pass Filter
rp = 3; % passband ripple
rs = 60; % stopband attenuation
fs = 20000; % sampling frequency
wp = 4200 / 10000;
ws = 5000 / 10000;
[n, wn] = buttord(wp, ws, rp, rs);
[b, a] = butter(n, wn,'low'); % Calculate filter coefficients
fvtool(b, a);
```

## Result

Thus the **IIR Low pass** was performed and displayed the graph in FVTOOL using MATLAB.

## IIR HIGH PASS FILTER

## Aim

To perform a **IIR High pass filter Using MATLAB.**

## Requirements

Matlab 2007 later

## Procedure

☞OPEN MATLAB

☞File **→** New **→** Script. – Type the program in untitled window

☞File **→** Save **→** type filename.m in matlab workspace path

☞Debug **→** Run. Wave will displayed at Figure dialog box.

## Program

```
%Program - Butterworth Filter
%High Pass Filter
rp = 3; % passband ripple
rs = 60; % stopband attenuation
fs = 20000; % sampling frequency
wp = 4200 / 10000;
ws = 5000 / 10000;
[n, wn] = buttord(wp, ws, rp, rs);
[b, a] = butter(n, wn, 'high'); % Calculate filter coefficients
fvtool(b, a);
```

## Result

Thus the IIR High pass was performed and displayed the graph in FVTOOL using MATLAB.

## CALCULATION OF FFT

## Aim

To perform a **FFT Operation Using MATLAB.**

## Requirements

Matlab 2007 later

## Procedure

☞OPEN MATLAB

☞File New Script. – Type the program in untitled window

☞File Save type filename.m in matlab workspace path

☞Debug Run. Wave will displayed at Figure dialog box.

## Program

```
%Y = fft(X) returns the discrete Fourier transform (DFT) of vector X,
%computed with a fast Fourier transform (FFT) algorithm
clear all;
Xn = [1, 1, 1, 0];
N = length (Xn);
x = fft (Xn, N);
subplot(2,2,1);
stem(Xn);
title('Input sequence ');
xlabel('Length of Input Sequence');
ylabel('Input Values');
subplot(2,2,2);
stem(real(x));
title('Output real sequence ');
xlabel('Real Output Length');
ylabel('Real Values');
subplot(2,2,3);
stem(imag(x));
title('Output imag sequence ');
xlabel('Imag Output Length');
ylabel('Imag Values');
```

## Result

Thus the FFT of signal was performed and displayed the graph using MATLAB.

## DECIMATION BY POLYPHASE DECOMPOSITION

## Aim

To perform a Decimation Operation Using MATLAB.

## Requirements

Matlab 2007 later

## Procedure

☞OPEN MATLAB

☞File **→** New **→** Script. – Type the program in untitled window

☞File **→** Save **→** type filename.m in matlab workspace path

☞Debug **→** Run. Wave will displayed at Figure dialog box.

## Program

```
%The input signal x[n] is a 1 kHz sinusoid sampled at 44.1 kHz.
N = 159;
Fs = 44.1e3;
n = 0:N-1;
x = sin(2*pi*n*1e3/Fs);
M = 3; % Decimation factor
h1 = mfilt.firdecim(M); % Default filter
% Display the output of the Direct-Form FIR Polyphase Decimator
%and overlay a shifted version of the original signal.
stem(tx,x,'k');
hold on;
stem(ty,y1,'filled');
axis([0 90 -Inf Inf]);
legend('Original signal','Decimated signal');
xlabel('Samples');
ylabel('Amplitude');
```

## Result

Thus the Decimation was performed and displayed the graph using MATLAB.