Top Banner
IMPLEMENTATION USING DSP PROCESSOR
61
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lab Manual - Processor

IMPLEMENTATION USING DSP PROCESSOR

Page 2: Lab Manual - Processor

Exp. No. :Date:

GENERATION OF SIGNALS

AIM:

To perform the following programs using TMS320C50 processor:

Square wave generation

Sine wave generation

Sawtooth wave generation

Triangular wave generation

COMPONENTS REQUIRED:

1. C50 processor kit

2. CRO

3. Function generator

4. Power cable and probes

PROCEDURE:

1. Open the C50 debugger software.2. In Menu bar, choose Serial => Port settings => Set to Com1.3. Go to Project => New Project and save it as .dpj file.4. Go to File => New => Assembly file, then type the program and save it.5. In Assembly folder, choose the option Add file to Project and save it.6. Similarly in .cmd file, Add file to project and save it.7. Now go to Project in Menu bar and choose the option Buuld and in Serial

=> Load program.8. Now the program will be loaded in the kit.9. In Communication window, type input and view the output.10.Close the window.

Page 3: Lab Manual - Processor

CODING:

SQUARE WAVE GENERATION: .mmregs .textstart: ldp #100h lacc #0fffh ;change this value for amplitude.loop: sacl 0 rpt #0ffh ;change this value for frequency. out 0,04 ;address for dac. cmpl b loop .end;

OUTPUT:

Page 4: Lab Manual - Processor

SINE WAVE GENERATION:

WITH THESE DEFAULT VALUES SINE GENERATED IS 100 HZ.INCFREQ .set 10 ;minimum value 1 - change for increasing frequency every count will increase frequency in steps of 100hzDECFREQ .set 0 ;minimu value 0 - change for decreasing frequency every count will decrease frequency by halfLENGTH .set 360AMPLITUDE .set 5delay .set 7 ;change to increase/decrease frequency in ;different steps;TEMP .set 0TEMP1 .set 1.mmregs.textSTART: LDP #100H SPLK #TABLE,TEMP ;load start address of table lar AR2,#( (LENGTH/INCFREQ)+(LENGTH*DECFREQ) )-1 lar ar3,#DECFREQ ;repeat counter for reducing frequencyCONT: CALL DELAY LACC TEMP ;load address of sine value TBLR TEMP1 ;read sine data to TEMP1 LT TEMP1 MPY #AMPLITUDE PAC SACL TEMP1 mar *,ar3 banz repeat,*- lar ar3,#DECFREQ ;repeat counter for reducing frequency LACC TEMP ADD #INCFREQ ;increase table value

Page 5: Lab Manual - Processor

repeat: SACL TEMP ;store it OUT TEMP1,4 ;send sine data to DAC MAR *,AR2 BANZ CONT,*- b STARTDELAY: lar ar7,#delay mar *,ar7back: banz back,*- ret;TABLE .word XXX

OUTPUT:

Page 6: Lab Manual - Processor

SAWTOOTH WAVE GENERATION : .mmregs .textstart: ldp #120h lacc #0h ;change lower amplitude sacl 0loop: lacc 0 out 0,04h add #05h ;change frequency sacl 0 sub #0fffh ;change upper amplitude bcnd loop,leq b start .end;

OUTPUT:

Page 7: Lab Manual - Processor

TRIANGULAR WAVE GENERATION:

AMPLITUDE .SET 4FREQ .SET 350TEMP .SET 0; .mmregs

.textSTART: LDP #100H splk #0,TEMPCONT1: lar AR2,#FREQCONT: out TEMP,4 LACC TEMP ADD #AMPLITUDE SACL TEMP MAR *,AR2 BANZ CONT,*- LAR AR2,#FREQCONTx: OUT TEMP,4 LACC TEMP SUB #AMPLITUDE SACL TEMP MAR *,AR2 BANZ CONTx B CONT1 .end

Page 8: Lab Manual - Processor

OUTPUT:

RESULT:

Thus fundamental waveform generations are performed using DSP processor.

Page 9: Lab Manual - Processor

Exp. No. :Date:

CONVOLUTION

AIM:

To perform the following programs using TMS320C50 processor: Linear convolution Circular convolution

COMPONENTS REQUIRED:

1. C50 processor kit2. CRO3. Function generator4. Power cable and probes

THEORY:

In general, convolution operations is of 2 types. They are:1. Linear convolution2. Circular convolution

Linear convolution is a complex operation and this can be carried out

using MAC and MACD instructions. It is given by:

y(n)=x(n)*h(n)

where y(n) is the output sequence and x(n) & h(n) are the input sequences

Convolution in frequency domain is calculated by process of multiplication and

accumulation with proper shifting of sequences. MAC and MACD instructions

are used in TMS processor for this purpose of performing linear convolution.Differences between MAC and MACD:

MAC MACDThe syntax is:

MAC pma,{ind},[nextARP] (or)

MAC pma,dma

The syntax is:

MACD pma, dma (or)

MACD pma,{ind},[nextARP]

Data shift is not automatically produced It provides shifting automatically

Page 10: Lab Manual - Processor

CIRCULAR CONVOLUTION:

Consider two finite duration sequence of length N namely x(n) and y(n). Their respective N-point DFT’s are

Multiplying the DFT’s together ,the result is a DFT, say Z(k) of a sequence z(n) of length N.

Z(k) = x(k).Y(k), k=0,1,2,3,………………(N-1)

The IDFT of Z(k) is given as

Substituting the values and rearranging the above equation we get the following term,

The inner sum in the brackets of the above equation is of the form

where a is defined as

.

we observe that a=1 when m-n-1 is a multiple of N. On the other hand aN =1 for any value a=0.

Consequently the above equation reduces to

p is an integer

Substituting this result in Z(n), we get

Page 11: Lab Manual - Processor

This expression has the form of a convolution sum. It is not the linear convolution which relates the output sequences of linear system to the input sequence of x(n) and the impulse response h(n). Instead, the convolution sum involves the index (m-n)N and is called the CIRCULAR CONVOLUTION. Thus we conclude that multiplication of the DFT’s of two sequences is equivalent to the circular convolution of two sequences in time domain.

PROCEDURE:

1. Open the C50 debugger software.2. In Menu bar, choose Serial => Port settings => Set to Com1.3. Go to Project => New Project and save it as .dpj file.4. Go to File => New => Assembly file, then type the program and save it.5. In Assembly folder, choose the option Add file to Project and save it.6. Similarly in .cmd file, Add file to project and save it.7. Now go to Project in Menu bar and choose the option Buuld and in Serial

=> Load program.8. Now the program will be loaded in the kit.9. In Communication window, type input and view the output.10.Close the window.

LINEAR CONVOLUTION:

CODING:;--------------------------------------------------------------------; LINEAR CONVOLUTION " y(n) = x(n)*h(n)";-------------------------------------------------------------------- .mmregs .textSTART:LDP #100H

LAR AR1,#(8100H+4H) ; x(n) Input Location (8100h)

ZACMAR *,AR1RPT #2HSACL*+

Page 12: Lab Manual - Processor

LAR AR1,#(8200H+4H) ; h(n) Input Location (8200h)ZACMAR *,AR1RPT #2HSACL*+

LAR AR3,#(8300H+6H) ; y(n) Output Location (8200h)LAR AR4,#06H ; Count-1 ie, N1+N2-1

;Multiply & Accumulate:;----------------------

Next_YN:LAR AR1,#8100HLAR AR2,#(8200H+6H)LAR AR0,#06HZACSACL0H

MAR *,AR1LT *+,AR2

Loop_MAC:MPY *-,AR1LTP *+,AR0ADD 0HSACL0HBANZ Loop_MAC,*-,AR2

LACC 0HMAR *,AR3SACL*- ; Store O/P Data "y(n)"

; Shift x(n) Values:

LAR AR1,#(8100H+6H) ; x(n)LAR AR2,#5H ; Shift Count-1

LAR AR0,#2H ; Index Value 2HMAR *,AR1LACC *-SACL1H

Page 13: Lab Manual - Processor

Shift_XN:LACC *+

SACL*0-,AR2BANZ Shift_XN,*-,AR1MAR *+LACC 1HSACL*,AR4

BANZ Next_YN,*-NOP

H1: B H1;--------------------------------------------------------------------

OUTPUT :

;INPUT ( x(n) ); 8100 - 1; 8101 - 3; 8102 - 1; 8103 - 3

;INPUT ( h(n) ); 8200 - 1; 8201 - 2; 8202 - 1; 8203 - 0

;OUTPUT (y(n) )

; 8300 - 1; 8301 - 5; 8302 - 8; 8303 - 8; 8304 - 7; 8305 - 3; 8306 - 0;----------------------------------------------------------------

Page 14: Lab Manual - Processor

CIRCULAR CONVOLUTION

Mnemonic Comments

LDP #0100H Load data pointer with value of 0100

LACC #00H Load the accumulator with the address 8000

SUB #01H Subtract 1 from accumulator and store it

LAR AR0,1H Load AR0 with content of 8001

LAR AR1,#8060H Load AR1 with 8060

LAR AR2,#8100H Load AR1 with 8100

COPYX2:MAR *,AR1 Modify ARP to AR2

LACC *+ Load acc with current auxiliary register and increment it

MAR *,AR2 Modify ARP to AR2

SACL *+ Store acc lower content at AR2 and increment

MAR *,AR0 Modify ARP to AR0

BANZ COPYX2,* Branch on no zero to copy x2.decrement AR0

LAR AR0,1H Load AR0 with content of 8001

LAR AR2,#8010H Load AR2 with immediate value 8010

LOOP3:LAR AR1,#8060 Load AR1 with immediate value 8060

LAR AR3,#8050 Load AR3 with immediate value 8050

LAR AR4,1H Load AR4 with 8001

ZAP Zero acc and product register

LOOP:MAR *,AR3 Modify ARP to AR3

Page 15: Lab Manual - Processor

LT*+ Load T register with AR3 and increment

MAR *,AR1 Modify ARP to AR1

MPY *+ Multiply content of T register and AR1 and store result in

AR1

SPL 5H Store product register to memory location 05

ADD 5H Add content of location 05 with acc

MAR *,AR4 Modify ARP to AR4

SACL *+ Store acc lower content at AR2 and increment

CALL ROTATE Call the sub program rotate

LOOP2:MAR *,AR0 Modify ARP to AR0

BANZ LOOP3,*- Branch on no zero to loop3.decrement AR0

H: B H End

ROTATE :LDP # 0100H Load data pointer with value of 0100

LACC 01H Load the accumulator with the address 8001

SUB 02H Subtract 1 from accumulator and store it

LACC 0050H Load the accumulator with the address 8050

SACB Store acc content in acc buffer

LAR AR3,#8051 Load AR3 with immediate value 8051

LAR AR5,#8070 Load AR5 with immediate value 8070

LAR AR6,2H Load AR6 with content 8002

Page 16: Lab Manual - Processor

LOOP1:MAR *,AR3 Modify ARP to AR3

LACC *+ Load the accumulator with AR3 and increment

MAR *,5 Modify ARP to AR5

SACL *+ Store acc lower content at AR5 and increment

MAR *,6 Modify ARP to AR6

BANZ LOOP1,*- Branch on no zero to loop1.decrement AR0

LACB Load acc with immediate value 8070

MAR *,AR5 Modify ARP to AR5

SACL *+ Store acc lower content at AR5 and increment

LACC #8070H Load the accumulator with AR3 and increment

SAMM BMAR Store acc in memory mapped register BMAR

LAR AR3,#8050H Load AR5 with immediate value 8070

MAR *,AR3 Modify ARP to AR3

RPT #3H Repeat nest instruction 4 times

BLDD BMAR,*+ Block move from data memory to data memory.BAMR is

incremented by 1.AR is incremented by 1

RET Return

Page 17: Lab Manual - Processor

SAMPLE INPUT:

Page 18: Lab Manual - Processor

x(n):

Memory location

Data

8050 0001

8051 0002

8052 0003

8053 0004

h(n):

Memory location Data

8060 0005

8061 0006

8062 0007

8063 0008

SAMPLE OUTPUT:

Memory location

Data

8010 0046

8011 0040

8012 003E

8013 0040

RESULT:

Thus the linear and circular convolution of two entered sequence is performed using DSP processor.

Exp. No.:Date:

Page 19: Lab Manual - Processor

4 - POINT DFT COMPUTATION

AIM:

To compute the 4 – point DFT of a given sequence using C50 debugger.

THEORY:

The DFT of a finite sequence x(n) is obtained by sampling the fourier transform X(e^jw) at N equally spaced points over the interval 0 < w <2*pi/N.

The DFT, denoted by X(k) is defined as:

X(k) = X(e^jw)/w = 2*pi*k/N 0 <= k <= N-1

The N-point DFT of the given sequence x(n) is given by:

N-1

X(k) = x(n)e^ (-j*2*pi*k*n/N) 0 <= k <= N-1

n=0

The fourier transform X(e^jw) is periodic in w, with period 2*pi and its inverse fourier transform is equal to discrete time sequence x(n).the 4 point DFT of given sequence is given by:

X(k) = X(e^jw)/w = 2*pi*k/4 0 <= k <= 3

When X(e^jw) is sampled with sampling period 2*pi/4 the corresponding discrete time sequence x(n) becomes periodic in time with period 4.

3

Page 20: Lab Manual - Processor

X(k) = x(n)e^ (-j*2*pi*k*n/4) 0 <= k <= 3

n=0

ALGORITHM:

1. Initially set value of

N=4,Pi=180,k=6,I=8,CON=5,temp=4,count=2,input=8000,real=8010,im

g=8020,cossin=8030

2. Load data page of 0100H.store a long immediate value of 2 in the

memory location of 800A.

3. Load auxiliary register pointer AR0 with a value of

count,AR6=1,AR3=cossin. Modify ARP to AR3 .Repeat next

instruction 9 times.

4. Block move from program memory to data memory. Load T register

with a content of 800A.multiply T register with a PI store PREG content

in 8005.

5. Load AR2=img. Store a long immediate value in memory specified by

auxiliary register pointer. Load auxiliary register AR0 with a value of

count.

6. Load TREG with an con value(2*PI) multiply with k and store in

PR.Store PR in 8001.

7. In order to find the value of N call the sub routine.

8. Load ACC with temp. Modify ARP to AR2.store the content of ACC in

8020.then again initialize ACC to 0.

9. Add the content of ACC with 1 and result is stored in k. Then modify

ARP to AR0.

10. Check whether AR0 is 0.If not modify ARP to AR6.Again check

whether AR6 is 0.If not decrement and goto step 16.

11. Initialize AR1=03,AR2=8020,ARP=AR2.

Page 21: Lab Manual - Processor

12. Load ACC with content of 8020 and compliment it. Then add with it

and store it.

13. Then modify ARP to AR7 .Store ACC lower content in AR7.Then

modify ARP to AR1.

14. Check whether AR1 is 0.If not decrement AR1 by 1 and then goto step

11.

15. Halt

16. Call the sub program result

17. Initialize AR3=cossin, ARP to AR3

18. Move the block of data from program memory to 8030(for imaginary

part)

19. Goto step 9 unconditionally.

20. Initialize data pointer with page 100.

21. Initialize AR1=count,AR3=cossin,AR4=input.Store long immediate

value 0 in temp(8004)

22. Store long immediate value (N=4) in 8009

23. Store the value 0 in 800C.Then load with 0.Store ACC in acc buffer.

24. Load T register with the content of 8001(2*PI*k).Then multiply with I

and store the result in PREG.Then again store PREG in ACC.

25. Subtract unconditionally the content of 8009(2*PI*k*I/N) from

ACC.Then store ACC content in 800B.

26. Load ACC with content of 800B.Then subtract the content of 800C from

ACC.

27. If content of ACC and 800C are equal branch unconditionally.Then load

ACC content with 800C.Add it with 90 and store in 800C.Modify ARP

to AR3.

28. The content of AR3 is added with 1 and result is stored in AR3.Then

jump unconditionally to step 26.

29. Load ACC with temp.Modify ARP to AR3.Then load ACC buffer with

content of ACC.

30. Multiply each value(x(i)) with TREG and result is stored in AR3.

Page 22: Lab Manual - Processor

31. Add the content of ACC and PREG and result is stored in ACC.

32. Store the content of ACC in temp(8004).Then load ACC buffer with

content of ACC.

33. Add ACC with 1 and store the content of ACC in acc buffer.Modify

ARP to AR1.

34. Check whether AR1 is 0.If not decrement AR1 content and goto step 20.

35. Return to main program.

36. Lo ACC with img(8020)

37. Store the content of acc in memory mapped register BMAR

38. Load AR5 with real(8010).Modify ARP to AR5.

39. Block move data from 8020-8023 to 8010-8013.BMAR is increment by

1.After each step while AR5 is decrement by 1.

40. Then result to main program step 17.

INITIALISATION SEQUENCE:

.MMREGS

.TEXT

N .set 4H

PI .set 180

K .set 06H

I .set 08H

Page 23: Lab Manual - Processor

CON .set 05H

TEMP .set 04H

COUNT .set 3H

INPUT .set 8000H

REAL .set 8010H

IMG .set 8020H

COSSIN .set 8030H

PROGRAM:

Mnemonic CommentsLDP #100H Load the data pointer with a value of 100

SPLK #2,000A Store the long immediate value 2 in 8000A

LAR AR0,#COUNT Load the auxiliary register pointer AR0 with value of

count

LAR AR6,#1 Load the AR6 with value of 01 in memory pointed by

AR6

LAR AR3=cossin Load the AR3 with value of cossin in memory pointed

by AR3

MAR *,AR3 Modify ARP to AR3

RPT #9 Repeat the next instruction 9 times

BPLD #TABLE,*+ Block move from program memory to data memory of

table value to 8050

LT 000A Load the T register with content of memory in 800A

MPY #PI Multiply the value TREG and PI and store in PREG

SPL CON Store the product register low to 8005

Page 24: Lab Manual - Processor

Loop4:

LAR AR2 #IMG

Load the AR2 with value of imaginary value

SPLK #0 Store the long immediate value of 0 for k,is interrupt

flat register

LAR AR0,#COUNT Load the Ar0 with the count value

Loop3:

LT CON(2*PI)

Load TREG with value of constant as 2 and with PI

and result is stored in PREG

MPY K Multiply k with PI and 2.the result is stored in PREG

SPL 0007 Store long immediate value(2*PI*k)in 8007

CALL MUL Call the sub routine MUL

LACC TEMP Load the acc of matching value in temp. Matching is

done only once

MAR *,AR2 Modify ARP to AR2

SACL *+ Store the lower content in 8020 and increment AR2 by

1

LACC K,0 Load acc with k as 0

ADD #1H Add1 with acc and result is stored in acc

SACL K Store acc lower with value of k as 1

MAR *,AR0 Modify ARP to AR0

BANZ LOOP3,*- Branch on no zero to loop3.Then decrement ARP by 1

MAR *,AR6 Modify ARP to AR6

BANZ LOOP5,*- Branch on no zero to loop5.Then decrement ARP by 1

Loop5:

CALL REALT

Call the sub routine program Realt

LAR AR3,#COSSIN Load AR3 with value of cossin from table

MAR *,AR3 Modify ARP to AR3

Page 25: Lab Manual - Processor

RPT #9 Repeat the next instruction 9 times

BLDD #TABLE1,*+ Block move from program memory to data memory

value of table and increment

BLOOP4 Branch unconditionally to loop4

MUL:

LDP #100

Load data page 100

LAR AR1,#COUNT Load AR1 with value of count

LAR AR3,#COSSIN Load AR3 with value of cossin

LAR AR4,#INPUT Load AR4 with value of input from table

SPLK #0H,TEMP Store the long immediate value of 0h to temp

SPLK #N,0009 Store the long immediate value N to 8009

SPLK #0,000C Store the long immediate value of 0 to 800C

LACC #0H Load the acc with immediate value of 0

SACB* Store the content of acc to acc buffer

Loop:

SACL I

Store the acc lower content with value of I

LT 0007 Load TREG with value of 2*PI*I in 8007

MPY I Multiply the acc content and value of I and store the

result in acc

PAC Product pregister value is stored in acc

RPT #15 Repeat the next instruction 15 times

SUBC 0009H Subtract the acc content and CREG and the result is

stored in acc

SACL 000B Store the acc lower content in 800B

Loop2:

LACC 000BH

Load the acc value in memory location 800B

Page 26: Lab Manual - Processor

SUB 000C Subtract the acc content and CREG and the result is

stored in acc

BCND Loop1,EQ Branch unconditionally to loop1 if equal branch out

ADD #90 Add the acc content and 90

SACL 000C Store the result in acc lower at memory location 800C

MAR *,AR3 Modify ARP to AR3

ADRK #1H Current ARP is incremented by 1

BLOOP2 Branch unconditionally to loop2

Loop1:

LACC TEMP

Load acc with value of temp

MAR *,AR3 Modify ARP to AR3

MPY *+ Multiply the acc content input value. Then decrement

A RP by 1

APAC Add product register and accumulator

LACB Load the acc buffer to acc

ADD #1 Add the acc value with 1 and result is stored in acc

SACB Store the acc buffer from acc

MAR *,AR1 Modify ARP to AR1

BANZ Loop,*- Branch on no zero to loop. Then decrement ARP by 1

RET Return to main program

REALT:

LACC #IMG

Load acc with value of imaginary

SAMM BMAR Store acc in memory mapped register BMAR

LAR AR3,#REAL Load AR3 with real value from table

MAR *,AR5 Modify ARP to AR5

RPT #3 Repeat the next instruction 4 times

Page 27: Lab Manual - Processor

BLDD BAMR,*+ Block move data from 8020-8023 to 8010-8013

RET Return to program

TABLE(COS VALUES)

.WORD 00001H

.WORD 00000H

.WORD 0FFFFH

.WORD 00000H

.WORD 00001H

.WORD 00000H

.WORD 0FFFFH

.WORD 00000H

.WORD 00001H

.WORD 00000H

TABLE(SIN VALUES)

.WORD 00000H

.WORD 00001H

.WORD 00000H

.WORD 0FFFFH

.WORD 00000H

.WORD 00001H

.WORD 00000H

.WORD 0FFFFH

.WORD 00001H

.WORD 00001H

SAMPLE INPUT:

Memory location

Data

8000 0001

8001 0001

Page 28: Lab Manual - Processor

8002 0000

8004 0000

SAMPLE OUTPUT:

Memory location

Data

8010 00028011 0001

8012 00008013 0001

IMAGINARY:

Memory location

Data

8020 0000

8021 FFFF8022 0000

8023 0001

RESULT: Thus the 4 point DFT is computed for the given sequence using C50 debugger.

Exp. No. :Date:

IMPLEMENTATION OF FIR FILTERS

AIM:

To design assembly level program for FIR filters using DSP

processor.

COMPONENTS REQUIRED:

1. C50 processor kit

2. CRO

3. Function generator

Page 29: Lab Manual - Processor

4. Power cable and probes

PROCEDURE:

1. Open the C50 debugger software.2. In Menu bar, choose Serial => Port settings => Set to Com1.3. Go to Project => New Project and save it as .dpj file.4. Go to File => New => Assembly file, then type the program

and save it.5. In Assembly folder, choose the option Add file to Project and

save it.6. Similarly in .cmd file, Add file to project and save it.7. Now go to Project in Menu bar and choose the option Buuld

and in Serial => Load program.8. Now the program will be loaded in the kit.9. In Communication window, type input and view the output.10.Close the window.

FIR LOWPASS:

CODING :* Approximation type: Window design - Blackmann Window* Filter type: Lowpass filter* Filter Order: 52* Cutoff frequency in KHz = 3.000000

.mmregs

.text

Page 30: Lab Manual - Processor

B STARTCTABLE:

.word 0FFE7H ;Filter coefficients n=0

.word 0FFD3H

.word 0FFC6H

.word 0FFC4H

.word 0FFD0H

.word 0FFECH

.word 018H

.word 051H

.word 08CH

.word 0B9H

.word 0C2H

.word 092H

.word 01AH

.word 0FF5FH

.word 0FE78H

.word 0FD9AH

.word 0FD10H

.word 0FD30H

.word 0FE42H

.word 071H

.word 03B5H

.word 07CAH

.word 0C34H

.word 01054H

.word 01387H

.word 01547H

.word 01547H

.word 01387H

.word 01054H

.word 0C34H

.word 07CAH

.word 03B5H

.word 071H

Page 31: Lab Manual - Processor

.word 0FE42H

.word 0FD30H

.word 0FD10H

.word 0FD9AH

.word 0FE78H

.word 0FF5FH

.word 01AH

.word 092H

.word 0C2H

.word 0B9H

.word 08CH

.word 051H

.word 018H

.word 0FFECH

.word 0FFD0H

.word 0FFC4H

.word 0FFC6H

.word 0FFD3H

.word 0FFE7H ;Filter coefficients n=52* Move the Filter coefficients * from program memory to data memorySTART:

MAR *,AR0 ;This block moves the filter coefficient from pgm memory to data memory.

LAR AR0,#0200HRPT #33HBLKPCTABLE,*+SETC CNF

* Input data and perform convolutionISR: LDP #0AH

LACC #0SACL0OUT 0,05IN 0,06HLAR AR7,#0

Page 32: Lab Manual - Processor

MAR *,AR7BACK: BANZ BACK,*-

IN 0,4NOP NOPNOP NOPMAR *,AR1LAR AR1,#0300HLACC 0AND #0FFFHSUB #800HSACL*LAR AR1,#333HMPY #0ZACRPT #33HMACD 0FF00H,*- ;CONVOLUTION

OPERATIONAPACLAR AR1,#0300HSACH * LACC *ADD #800hSACL*OUT *,4LACC #0FFHSACL0OUT 0,05NOPB ISR

.endFIR BANDPASS:

CODING:

* Approximation type: Window design - Blackmann Window

Page 33: Lab Manual - Processor

* Filter type: bandpass filter

* Filter Order: 52

* lower Cutoff frequency in KHz = 3.000000Hz

* upper Cutoff frequency in KHz = 5.000000Hz

.mmregs

.text

B START

CTABLE:

.word 024AH

.word 010FH

.word 0FH

.word 0FFECH

.word 0C6H

.word 0220H

.word 0312H

.word 02D3H

.word 012FH

.word 0FEBDH

.word 0FC97H

.word 0FBCBH

.word 0FCB0H

.word 0FE9EH

.word 029H

Page 34: Lab Manual - Processor

.word 0FFDCH

.word 0FD11H

.word 0F884H

.word 0F436H

.word 0F2A0H

.word 0F58AH

.word 0FD12H

.word 075FH

.word 01135H

.word 01732H

.word 01732H

.word 01135H

.word 075FH

.word 0FD12H

.word 0F58AH

.word 0F2A0H

.word 0F436H

.word 0F884H

.word 0FD11H

.word 0FFDCH

.word 029H

.word 0FE9EH

.word 0FCB0H

Page 35: Lab Manual - Processor

.word 0FBCBH

.word 0FC97H

.word 0FEBDH

.word 012FH

.word 02D3H

.word 0312H

.word 0220H

.word 0C6H

.word 0FFECH

.word 0FH

.word 010FH

.word 024AH

* Move the Filter coefficients from program memory to data memory

START:

MAR *,AR0

LAR AR0,#0200H

RPT#33H

BLKP CTABLE,*+

SETC CNF

* Input data and perform convolution

ISR:LDP #0AH

LACC #0

Page 36: Lab Manual - Processor

SACL 0

OUT 0,05 ;pulse to find sampling frequency

IN 0,06H

LAR AR7,#0 ;change value to modify sampling freq.

MAR *,AR7

BACK: BANZ BACK,*-

IN 0,4

NOP

NOP

NOP

NOP

MAR *,AR1

LAR AR1,#0300H

LACC 0

AND #0FFFH

SUB #800H

SACL *

LAR AR1,#333H

MPY #0

ZAC

RPT#33H

MACD 0FF00H,*-

APAC

Page 37: Lab Manual - Processor

LAR AR1,#0300H

SACH * ;give as sach *,1 incase of overflow

LACC *

ADD #800H

SACL *

OUT *,4

LACC #0FFH

SACL 0

OUT 0,05

NOP

B ISR

.end

OBSERVATION:

FIR LOW PASS FILTER Vin=

Frequency ( Hz ) Amplitude ( V )

Gain= 20 log ( Vo/ Vin)

( dB )

Page 38: Lab Manual - Processor

FIR BAND PASS FILTER Vin=

Frequency ( Hz ) Amplitude ( V )

Gain= 20 log ( Vo/ Vin)

( dB )

OUTPUT:

FIR LOW PASS FILTER

Page 39: Lab Manual - Processor

FIR BAND PASS FILTER

Page 40: Lab Manual - Processor

RESULT:

Thus FIR filters have been implemented using DSP processor.

Exp. No. :Date:

IMPLEMENTATION OF IIR FILTERS

AIM:

To design assembly level program for IIR filters using DSP

processor.

COMPONENTS REQUIRED:

1. C50 processor kit

2. CRO

3. Function generator

4. Power cable and probes

PROCEDURE:

Page 41: Lab Manual - Processor

1. Open the C50 debugger software.2. In Menu bar, choose Serial => Port settings => Set to Com1.3. Go to Project => New Project and save it as .dpj file.4. Go to File => New => Assembly file, then type the program

and save it.5. In Assembly folder, choose the option Add file to Project and

save it.6. Similarly in .cmd file, Add file to project and save it.7. Now go to Project in Menu bar and choose the option Buuld

and in Serial => Load program.8. Now the program will be loaded in the kit.9. In Communication window, type input and view the output.10.Close the window.

IIR LOWPASS:CODING: .MMREGS .TEXTTEMP .SET 0INPUT .SET 1T1 .SET 2T2 .SET 3T3 .SET 4;K .SET 315ehM .SET 4e9fh;cut-off freq is 1Khz. = Fc

Page 42: Lab Manual - Processor

;sampling frequency is 100 hz (ie) 0.1ms.; a = 2 * (355/113) * 1000 = 6283.18/1000 = 6.28 ;; divide by 1000 for secs; K = aT/(1+aT) = 6.28*0.1 / (6.28*0.1+1) = 0.3857; M = 1/(1+aT) = 1 / (6.28*0.1+1) = 0.61425;convert to Q15 format; K = K * 32767 = 12638.23 = 315Eh; M = M * 32767 = 20127.12 = 4E9Fh;Sampling Rate is 100 æs & Cut off Frequency is 1 Khz LDP #100H LACC #0 SACL T1 SACL T2 SACL TEMP OUT TEMP,4 ;CLEAR DAC BEFORE START TO WORKLOOP: LACC #0 SACL TEMP OUT TEMP,5 ;OUTPUT LOW TO DAC2 TO CALCULATE TIMING; IN TEMP,06 ;SOC; LAR AR7,#30h ;CHANGE VALUE TO MODIFY SAMPLING FREQ. ; sampling rate 100 sec.

MAR *,AR7BACK: BANZ BACK,*-; IN INPUT,4 ;INPUT DATA FROM ADC1

NOPNOP

; LACC INPUT AND #0FFFH SUB #800h SACL INPUT

Page 43: Lab Manual - Processor

; LT INPUT MPY #K PAC SACH T1,1;;;CALL MULT ----MULTIPLICATION TO BE DONE WITH K;;RESULT OF MULT IN T1; LT T2 ;PREVIOUS RESULT IN T2 MPY #M PAC SACH T3 ,1;;;CALL MULT ----MULTIPLICATION TO BE DONE WITH M;;RESULT OF MULT IN T3+; LACC T1 ADD T3 SACL T2 ADD #800h SACL TEMP OUT TEMP,4 ;OUTPUT FILTER DATA TO DAC1; LACC #0FFH SACL TEMP OUT TEMP,5 ;OUTPUT HIGH TO DAC2 TO CALCULATE TIMING; B LOOP

IIR BANDSTOP:CODING:.MMREGS.TEXTSTART:

LDP #100HNOPNOPNOP

Page 44: Lab Manual - Processor

LACC #00HLAR AR0,#00FFHLAR AR1,#8000HMAR *,AR1

LOOP: SACL *+,AR0BANZ LOOP,AR1

LOOP1:LACC #00HSACL 00HIN 0,06HLAR AR7,#30HMAR *,AR7

BACK: BANZ BACK,*-IN 0,04HNOPNOPNOPNOPLT 04HMPY #2FC4H

; MPY #05F8HPACSACH 24H,0

; SACH 24H,4LT 03H

MPY #99B2H; MPY #1336H

PACSACH 23H,0

; SACH 23H,4LT 02H

MPY #0DB29H; MPY #1B65H

PACSACH 22H,0

; SACH 22H,4LT 01H

MPY #99B2H; MPY #1336H

Page 45: Lab Manual - Processor

PACSACH 21H,0

; SACH 21H,4;LACC 03H

SACL 04HLACC 02HSACL 03HLACC 01HLACC 02H;

LACC 00HAND #0FFFHXOR #800HSUB #800HSACL 00HSACL 01HZAP

; DMOV 03H; DMOV 02H; DMOV 01H

LT 00HMPY #2FC4H

; MPY #05F8HPAC SACH 20H,0

; SACH 20H,4; LT 73H

MPY #2A22H; MPY #0544H

PACSACH 63H,0

; SACH 63H,4LT 72H

MPY #6761H; MPY #0CECH

PACSACH 62H,0

; SACH 62H,4LT 71H

MPY #0B6E8H; MPY #16DDH

Page 46: Lab Manual - Processor

PACSACH 61H,0

; SACH 61H,4; LACC 72H

SACL 73HLACC 71HSACL 72HLACC 70HSACL 71H

; DMOV 72H; DMOV 71H; LTD 70H

LT 70HMPY #0F184H

; MPY #1E30HPACSACH 60H,0; SACH 60H,4

LACC 20HSUB 21HADD 22HSUB 23HADD 24H

ADD 60HSUB 61HADD 62HSUB 63HSACL 70HADD #800HSACL 00H

; OUT 00H,1AHIN 0,04HB LOOP1NOP ; NOP

H:B HOBSERVATION:

IIR LOW PASS FILTER Vin=

Gain= 20 log ( Vo/ Vin)

Page 47: Lab Manual - Processor

Frequency ( Hz ) Amplitude ( V ) ( dB )

IIR BANDSTOP FILTER Vin=

Frequency ( Hz ) Amplitude ( V )

Gain= 20 log ( Vo/ Vin)

( dB )

Page 48: Lab Manual - Processor

OUTPUT:

IIR LOWPASS FILTER

IIR BANDSTOP FILTER

Page 49: Lab Manual - Processor

RESULT:

Thus IIR filters have been implemented using DSP processor.