Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
8 views6 pages

IIR Filter

IIR Filter

Uploaded by

senthilguruswamy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views6 pages

IIR Filter

IIR Filter

Uploaded by

senthilguruswamy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Ex.

No - 14
IIR Filter
Date:

AIM:
To implement IIR Filter using TMS320C6713 DSP processor.

APPARATUS REQUIRED:
VSK-6713 DSP Trainer Kit, PC

ALGORITHM:
1. Declare variables for filtering action
2. Assign addresses for variables
3. Initialize variables for filtering action
4. Give the co-efficients for IIR Second Order filter with sampling frequency 25Khz, Cut
off Frequency 1Khz
5. Perform Filtering Function
6. End the program

PROGRAM:
// sampling frequency 25khz
main()
{
// variable declaration for the filtering action
int t,r,x,k;
short b0,b1,b2,a1,a2;
short xn,xnm1,xnm2,yn,ynm1,ynm2;
unsigned int *soc,*adc1,*dac1;

// address assignmenat for the variables


soc = (unsigned int *)0x9004000c;
adc1 = (unsigned int *)0x90040008;
dac1 = (unsigned int *)0x90040008;

// variable initialization for the filtering action


xn= 0x0;
xnm1=0x0;
xnm2=0x0;
yn = 0x0;
ynm1=0x0;
ynm2=0x0;

// coefficient for iir low pass filter with the sampling frequency of 25Khz
// cutoff frequency of 1Khz
// filter order 2
// lpf
/*
b0=0x0037;
b1=0x006d;
b2=0x0037;
a1=0x0e5a6;
a2=0x0b36;
*/

// hpf
/*
b0=0x0d64;
b1=0x0e538;
b2=0x0d64;
a1=0x0e5a6;
a2=0x0b36;
*/

// bpf
/*
b0=0x01e8;
b1=0x0;
b2=0x0fe18;
a1=0x0e561;
a2=0x0c68;
*/

// BRF

b0=0x0e34;
b1=0x0e561;
b2=0x0e34;
a1=0x0e561;
a2=0x0c68;

// infinite loop for the filter starts here

while(1)
{

x = *(soc);
for(k=0;k<50;k++);
x = *(adc1);
x = x & 0x0fff;
x = x ^ 0x0800;
x = x - 0x0800;

xn = x;

r = 0;
// filtering action
r += (b0 * xn) >>12; // b0*xn
r += (b1 * xnm1)>>12; // b1*xnm1
r += (b2 * xnm2)>>12; // b2*xnm2
r -= (a1 * ynm1)>>12; // a1*ynm1
r -= (a2 * ynm2)>>12; // a2*ynm2
// move the result to yn
yn = r;
// convert it into integer
t = r;
// add the offset
t = t + 0x0800;
// send to dac
// port4 = t;

*dac1 = t;

// shift the datas from current to previous sample


xnm2=xnm1;
xnm1=xn;
ynm2=ynm1;
ynm1=yn;
}
}

OBSERVATION:

 Connect the function generator to the kit, and generate Sine Wave of appropriate
amplitude
 Connect the oscilloscope to Output
 Run the program
 Observe the appropriate response (Amplitude Variation according to the filter type)

RESULT:
Thus IIR Filter was implemented in TMS320C6713 processor.
Ex.No - 15
FIR Filter
Date:

AIM:
To implement FIR Filter using TMS320C6713 DSP processor.

APPARATUS REQUIRED:
VSK-6713 DSP Trainer Kit, PC

ALGORITHM:
1. Assign Sampling frequency, Cut off Frequency and filter order
2. Initialize addresses for ADC and DAC read write operations
3. Write functions / formulae for implementing the low pass filtering action
4. Calculate the filter co-efficients
5. Perform Filtering Function
6. End the program

PROGRAM:
#include<fastmath67x.h>
#include<math.h>
#define PI 3.14
void main()
{

const float Fsamp = 10000; //sampling frequency


int Fcut = 1500; //cut off frequency
int N = 40; //order
float Fc = Fcut/Fsamp;
float Wc = 2 * PI * Fc;

int *SocValue,*AdcValue;
int SocRead,*AdcStore;
int *DacOut;
short AdcOut;

int OutValue,Count,Inc;
float *Hd,*Hm;
float Val;

unsigned char *Led;

SocValue = (int *)0x9004000c;


AdcValue = (int *)0x90040008; //cpld address for adc read
AdcStore = (int *)0x80000000;

Hd = (float *)0x80010000;
Hm = (float *)0x80030000;
DacOut = (int *)0x90040008; //cpld address for dac write
Led = (unsigned char *)0x90040016;

//formulae implementation low pass filter


//filter co efficients calculation

for(Count = -2 * N; Count < 2 * N; Count++)


{
AdcStore[ Count ] = 0;
Hd[ Count ] = 0;
Hm[ Count ] = 0;
}

for(Count = -N/2; Count < N/2; Count++)

{
if(Count == 0)
Hd[Count] = 2 * Fc;

else
{
Val = sin(Wc * Count);
Hd[Count] = Val / (Count * PI);
}
}

Inc=0;
for(Count = -N/2; Count < N/2; Count++)
{
Hm[Inc] = Hd[Count];

Inc++;
}

while(1)
{

SocRead = *SocValue;
AdcOut = *AdcValue;

AdcOut &= 0x0fff; //masf 12 bits


AdcOut ^= 0x0800; //convert unipolar

*AdcStore = AdcOut;

OutValue = 0;

for(Count = 0; Count < N; Count++) //filter operation


OutValue += (*(AdcStore + Count) * *(Hm + Count));

for(Count = (N-1); Count >= 0; Count--)


*(AdcStore + Count + 1) = *(AdcStore + Count);

*DacOut = OutValue;
//for(Count = 0; Count < 750; Count++);
*Led = 1;
}
}

OBSERVATION:

 Connect the function generator to the kit, and generate Sine Wave of appropriate
amplitude
 Connect the oscilloscope to Output
 Run the program
 Observe the appropriate response (Amplitude Variation according to the filter type)

RESULT:
Thus FIR Filter was implemented in TMS320C6713 processor.

You might also like