You are on page 1of 47

IMPLEMENTATION USING

DSP 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.
2.
3.
4.
5.
6.
7.

Open the C50 debugger software.


In Menu bar, choose Serial => Port settings => Set to Com1.
Go to Project => New Project and save it as .dpj file.
Go to File => New => Assembly file, then type the program and save it.
In Assembly folder, choose the option Add file to Project and save it.
Similarly in .cmd file, Add file to project and save it.
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.

CODING:
SQUARE WAVE GENERATION:
.mmregs
.text
start:
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:

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 100hz
DECFREQ .set 0 ;minimu value 0 - change for decreasing frequency
every count will decrease frequency by half
LENGTH .set 360
AMPLITUDE .set 5
delay
.set 7 ;change to increase/decrease frequency in
;different steps;
TEMP .set 0
TEMP1 .set 1
.mmregs
.text
START:
LDP #100H
SPLK #TABLE,TEMP ;load start address of table
lar AR2,#( (LENGTH/INCFREQ)+(LENGTH*DECFREQ) )-1
lar ar3,#DECFREQ ;repeat counter for reducing frequency
CONT:
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
repeat:

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

OUTPUT:

SAWTOOTH WAVE GENERATION :

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

TRIANGULAR WAVE GENERATION:


AMPLITUDE .SET 4
FREQ
.SET 350
TEMP .SET 0
;
.mmregs
.text
START:
LDP #100H
splk #0,TEMP
CONT1:
lar AR2,#FREQ
CONT:
out TEMP,4
LACC TEMP
ADD #AMPLITUDE
SACL TEMP
MAR *,AR2
BANZ CONT,*LAR AR2,#FREQ
CONTx:
OUT TEMP,4
LACC TEMP
SUB #AMPLITUDE
SACL TEMP
MAR *,AR2
BANZ CONTx
B
CONT1
.end

OUTPUT:

RESULT:
Thus fundamental waveform generations are performed using DSP
processor.

Exp. No. :

Date:

CONVOLUTION
AIM:
To perform the following programs using TMS320C50 processor:
Linear convolution
Circular convolution
COMPONENTS REQUIRED:
1.
2.
3.
4.

C50 processor kit


CRO
Function generator
Power cable and probes

THEORY:
In general, convolution operations is of 2 types. They are:
1. Linear convolution
2. 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

MACD

The syntax is:

The syntax is:

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

MACD pma, dma (or)

MAC pma,dma
Data shift is not automatically produced

MACD pma,{ind},[nextARP]
It provides shifting automatically

CIRCULAR CONVOLUTION:
Consider two finite duration sequence of length N namely x(n) and y(n). Their
respective N-point DFTs are
N 1

X ( k ) = x(n)e

( j *2* *n*k ) / N

n =0

N 1

( j *2**n*k ) / N

Y ( k ) = y(n)e
n =0

, k = 0,1,2,3.......... .( N 1)

, k = 0,1,2,3.......... .( N 1)

Multiplying the DFTs 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

( N ) z ( k ) e (
N 1

Z ( n) = 1

j * 2* * n * k ) / N

k =0

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

( N ) x( n ) y( n ) e (

z( n) = 1

N 1

N 1

n=0

i =0

j *2* *( m n 1 ) *k ) N

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

= N , a = 1 and

= 1 a / (1 a )

k =0

where a is defined as
e ( j*2**( m n 1)*k ) N .

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
N 1

a
k =0

= N , l = ( m n + pN ) = ( m n ) N ,

p is an integer

= 0, otherwise
Substituting this result in Z(n), we get

( N ) x( n ) y ( m n )

z( n) = 1

N 1

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 DFTs 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
.text
START:
LDP
#100H
LAR
AR1,#(8100H+4H)
; x(n) Input Location
(8100h)
ZAC
MAR
*,AR1
RPT
#2H
SACL*+

LAR

AR1,#(8200H+4H)
ZAC
MAR
*,AR1
RPT
#2H
SACL*+
AR3,#(8300H+6H)
AR4,#06H

LAR
LAR

; h(n) Input Location (8200h)

; y(n) Output Location (8200h)


; Count-1 ie, N1+N2-1

;Multiply & Accumulate:


;---------------------Next_YN:
LAR
LAR
LAR
ZAC
SACL0H
MAR
LT

AR1,#8100H
AR2,#(8200H+6H)
AR0,#06H

MPY
LTP
ADD
SACL0H
BANZ
0H
MAR
SACL*-

*-,AR1
*+,AR0
0H

*,AR1
*+,AR2

Loop_MAC:

LACC

Loop_MAC,*-,AR2
*,AR3
; Store O/P Data "y(n)"

; Shift x(n) Values:


LAR
LAR

AR1,#(8100H+6H)
LAR
AR2,#5H
AR0,#2H
MAR
*,AR1
LACC
*SACL1H

; x(n)
; Shift Count-1
; Index Value 2H

Shift_XN:
LACC
*+
SACL*0-,AR2
BANZ
Shift_XN,*-,AR1
MAR
*+
LACC
1H
SACL*,AR4
BANZ
Next_YN,*NOP
H1:
B
H1
;-------------------------------------------------------------------OUTPUT :
;INPUT ( x(n) )
;
;
;
;

8100
8101
8102
8103

-1
-3
-1
-3

;INPUT ( h(n) )
;
;
;
;

8200
8201
8202
8203

-1
-2
-1
-0

;OUTPUT (y(n) )
;
8300 - 1
;
8301 - 5
;
8302 - 8
;
8303 - 8
;
8304 - 7
;
8305 - 3
;
8306 - 0
;----------------------------------------------------------------

CIRCULAR CONVOLUTION
Mnemonic

Comments

LDP #0100H

Load data pointer with value of 0100

LACC #00H

Load the accumulator with the address 8000

SUB #01H
LAR AR0,1H

Subtract 1 from accumulator and store it


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 *+
MAR *,AR2
SACL *+
MAR *,AR0
BANZ COPYX2,*
LAR AR0,1H

Load acc with current auxiliary register and increment it


Modify ARP to AR2
Store acc lower content at AR2 and increment
Modify ARP to AR0
Branch on no zero to copy x2.decrement AR0
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
ZAP
LOOP:MAR *,AR3
LT*+
MAR *,AR1
MPY *+

Load AR4 with 8001


Zero acc and product register
Modify ARP to AR3
Load T register with AR3 and increment
Modify ARP to AR1
Multiply content of T register and AR1 and store result in
AR1

SPL 5H

Store product register to memory location 05

ADD 5H
MAR *,AR4
SACL *+
CALL ROTATE
LOOP2:MAR *,AR0
BANZ LOOP3,*H: B H
ROTATE :LDP # 0100H
LACC 01H
SUB 02H
LACC 0050H
SACB

Add content of location 05 with acc


Modify ARP to AR4
Store acc lower content at AR2 and increment
Call the sub program rotate
Modify ARP to AR0
Branch on no zero to loop3.decrement AR0
End
Load data pointer with value of 0100
Load the accumulator with the address 8001
Subtract 1 from accumulator and store it
Load the accumulator with the address 8050
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
LOOP1:MAR *,AR3

Load AR6 with content 8002


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,*LACB
MAR *,AR5

Branch on no zero to loop1.decrement AR0


Load acc with immediate value 8070
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
MAR *,AR3
RPT #3H
BLDD BMAR,*+

Load AR5 with immediate value 8070


Modify ARP to AR3
Repeat nest instruction 4 times
Block move from data memory to data memory.BAMR is
incremented by 1.AR is incremented by 1

RET

Return

SAMPLE INPUT:

x(n):

h(n):

Memory
location

Data

8050

Memory location

Data

0001

8060

0005

8051

0002

8061

0006

8052

0003

8062

0007

8053

0004

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:

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
<= N-1
The N-point DFT of the given sequence x(n) is given by:
N-1

0 <= k

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

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,i
mg=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.
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.
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

.set

06H

.set

08H

CON

.set

05H

TEMP

.set

04H

COUNT .set

3H

INPUT

.set

8000H

REAL

.set

8010H

IMG

.set

COSSIN

.set

8020H
8030H

PROGRAM:
Mnemonic

Comments

LDP #100H
SPLK #2,000A
LAR AR0,#COUNT

Load the data pointer with a value of 100


Store the long immediate value 2 in 8000A
Load the auxiliary register pointer AR0 with value of

LAR AR6,#1

count
Load the AR6 with value of 01 in memory pointed by

LAR AR3=cossin

AR6
Load the AR3 with value of cossin in memory pointed

MAR *,AR3
RPT #9
BPLD #TABLE,*+

by AR3
Modify ARP to AR3
Repeat the next instruction 9 times
Block move from program memory to data memory of

LT 000A
MPY #PI
SPL CON
Loop4:

table value to 8050


Load the T register with content of memory in 800A
Multiply the value TREG and PI and store in PREG
Store the product register low to 8005
Load the AR2 with value of imaginary value

LAR AR2 #IMG


SPLK #0

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

LAR AR0,#COUNT
Loop3:

flat register
Load the Ar0 with the count value
Load TREG with value of constant as 2 and with PI

LT CON(2*PI)
MPY K
SPL 0007
CALL MUL
LACC TEMP

and result is stored in PREG


Multiply k with PI and 2.the result is stored in PREG
Store long immediate value(2*PI*k)in 8007
Call the sub routine MUL
Load the acc of matching value in temp. Matching is

MAR *,AR2
SACL *+

done only once


Modify ARP to AR2
Store the lower content in 8020 and increment AR2 by

LACC K,0
ADD #1H
SACL K
MAR *,AR0

1
Load acc with k as 0
Add1 with acc and result is stored in acc
Store acc lower with value of k as 1
Modify ARP to AR0

BANZ LOOP3,*MAR *,AR6


BANZ LOOP5,*Loop5:
CALL REALT
LAR AR3,#COSSIN
MAR *,AR3
RPT #9
BLDD #TABLE1,*+
BLOOP4
MUL:
LDP #100
LAR AR1,#COUNT
LAR AR3,#COSSIN
LAR AR4,#INPUT
SPLK #0H,TEMP
SPLK #N,0009
SPLK #0,000C
LACC #0H
SACB*
Loop:

Branch on no zero to loop3.Then decrement ARP by 1


Modify ARP to AR6
Branch on no zero to loop5.Then decrement ARP by 1
Call the sub routine program Realt
Load AR3 with value of cossin from table
Modify ARP to AR3
Repeat the next instruction 9 times
Block move from program memory to data memory
value of table and increment
Branch unconditionally to loop4
Load data page 100
Load AR1 with value of count
Load AR3 with value of cossin
Load AR4 with value of input from table
Store the long immediate value of 0h to temp
Store the long immediate value N to 8009
Store the long immediate value of 0 to 800C
Load the acc with immediate value of 0
Store the content of acc to acc buffer
Store the acc lower content with value of I

SACL I
LT 0007
MPY I

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


Multiply the acc content and value of I and store the

PAC
RPT #15
SUBC 0009H

result in acc
Product pregister value is stored in acc
Repeat the next instruction 15 times
Subtract the acc content and CREG and the result is

SACL 000B
Loop2:
LACC 000BH
SUB 000C

stored in acc
Store the acc lower content in 800B
Load the acc value in memory location 800B
Subtract the acc content and CREG and the result is
stored in acc

BCND Loop1,EQ
ADD #90
SACL 000C
MAR *,AR3
ADRK #1H
BLOOP2
Loop1:

Branch unconditionally to loop1 if equal branch out


Add the acc content and 90
Store the result in acc lower at memory location 800C
Modify ARP to AR3
Current ARP is incremented by 1
Branch unconditionally to loop2
Load acc with value of temp

LACC TEMP
MAR *,AR3
MPY *+

Modify ARP to AR3


Multiply the acc content input value. Then decrement

APAC
LACB
ADD #1
SACB
MAR *,AR1
BANZ Loop,*RET
REALT:

A RP by 1
Add product register and accumulator
Load the acc buffer to acc
Add the acc value with 1 and result is stored in acc
Store the acc buffer from acc
Modify ARP to AR1
Branch on no zero to loop. Then decrement ARP by 1
Return to main program
Load acc with value of imaginary

LACC #IMG
SAMM BMAR
LAR AR3,#REAL
MAR *,AR5
RPT #3
BLDD BAMR,*+
RET

Store acc in memory mapped register BMAR


Load AR3 with real value from table
Modify ARP to AR5
Repeat the next instruction 4 times
Block move data from 8020-8023 to 8010-8013
Return to program

TABLE(COS VALUES)
.WORD
.WORD
.WORD
.WORD
.WORD
.WORD
.WORD
.WORD

00001H
00000H
0FFFFH
00000H
00001H
00000H
0FFFFH
00000H

.WORD
.WORD

00001H
00000H

TABLE(SIN VALUES)
.WORD
.WORD
.WORD
.WORD
.WORD
.WORD
.WORD
.WORD
.WORD
.WORD

00000H
00001H
00000H
0FFFFH
00000H
00001H
00000H
0FFFFH
00001H
00001H

SAMPLE INPUT:
Memory
location

Data

8000

0001

8001

0001

8002

0000

8004

0000

SAMPLE OUTPUT:
Memory
location

Data

8010

0002

8011

0001

8012

0000

8013

0001

Memory

Data

IMAGINARY:

location
8020

0000

8021

FFFF

8022

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
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
B
START
CTABLE:
.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
.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 memory
START:
MAR *,AR0
;This block moves the
filter coefficient from pgm memory to data memory.
LAR AR0,#0200H
RPT #33H
BLKPCTABLE,*+
SETC CNF
* Input data and perform convolution
ISR: LDP #0AH
LACC
#0
SACL0
OUT 0,05
IN
0,06H
LAR AR7,#0
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,*OPERATION
APAC
LAR AR1,#0300H
SACH
*
LACC
*
ADD #800h
SACL*
OUT *,4
LACC
#0FFH
SACL0
OUT 0,05
NOP
B
ISR
.end
FIR BANDPASS:

;CONVOLUTION

CODING:
* Approximation type: Window design - Blackmann Window
* 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
.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
.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

SACL

OUT

0,05

IN

0,06H

LAR

AR7,#0

MAR

*,AR7

BACK:

BANZ

IN

0,4

;pulse to find sampling frequency

;change value to modify sampling freq.

BACK,*-

NOP
NOP
NOP
NOP
MAR

*,AR1

LAR

AR1,#0300H

LACC

AND

#0FFFH

SUB

#800H

SACL

LAR

AR1,#333H

MPY

#0

ZAC
RPT

#33H

MACD

0FF00H,*-

APAC
LAR

AR1,#0300H

SACH

LACC

ADD

#800H

SACL

OUT

*,4

LACC

#0FFH

;give as sach *,1 incase of overflow

SACL

OUT

0,05

NOP
B

ISR

.end
OBSERVATION:

FIR LOW PASS FILTER


Vin=
Gain= 20 log ( Vo/ Vin)
Frequency ( Hz )

Amplitude ( V )

( dB )

FIR BAND PASS FILTER


Vin=
Gain= 20 log ( Vo/ Vin)
Frequency ( Hz )

OUTPUT:
FIR LOW PASS FILTER

Amplitude ( V )

( dB )

FIR BAND PASS FILTER

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:

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
.TEXT
TEMP .SET 0
INPUT .SET 1
T1
.SET 2
T2
.SET 3
T3
.SET 4;
K
.SET 315eh

M
.SET 4e9fh
;cut-off freq is 1Khz. = Fc
;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
WORK
LOOP:
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 *,AR7
BACK:
BANZ
BACK,*;
IN
INPUT,4
;INPUT DATA FROM ADC1
NOP
NOP
; LACC INPUT
AND #0FFFH

SUB #800h
SACL INPUT
; 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

.TEXT
START:
LDP #100H
NOP
NOP
NOP
LACC #00H
LAR AR0,#00FFH
LAR AR1,#8000H
MAR *,AR1
LOOP:
SACL *+,AR0
BANZ LOOP,AR1
LOOP1:
LACC #00H
SACL 00H
IN 0,06H
LAR AR7,#30H
MAR *,AR7
BACK:
BANZ BACK,*IN 0,04H
NOP
NOP
NOP
NOP
LT 04H
MPY #2FC4H
;
MPY #05F8H
PAC
SACH 24H,0
;
SACH 24H,4
LT 03H
MPY #99B2H
;
MPY #1336H
PAC
SACH 23H,0
;
SACH 23H,4
LT 02H
MPY #0DB29H
;
MPY #1B65H

PAC
SACH 22H,0
;
SACH 22H,4
LT 01H
MPY #99B2H
;
MPY #1336H
PAC
SACH 21H,0
;
SACH 21H,4;
LACC 03H
SACL 04H
LACC 02H
SACL 03H
LACC 01H
LACC 02H;
LACC 00H
AND #0FFFH
XOR #800H
SUB #800H
SACL 00H
SACL 01H
ZAP
;
DMOV 03H
;
DMOV 02H
;
DMOV 01H
LT 00H
MPY #2FC4H
;
MPY #05F8H
PAC
SACH 20H,0
;
SACH 20H,4
;
LT 73H
MPY #2A22H
;
MPY #0544H
PAC
SACH 63H,0
;
SACH 63H,4
LT 72H
MPY #6761H
;
MPY #0CECH

PAC
SACH 62H,0
;
SACH 62H,4
LT 71H
MPY #0B6E8H
;
MPY #16DDH
PAC
SACH 61H,0
;
SACH 61H,4
;
LACC 72H
SACL 73H
LACC 71H
SACL 72H
LACC 70H
SACL 71H
;
DMOV 72H
;
DMOV 71H
;
LTD 70H
LT 70H
MPY #0F184H
;
MPY #1E30H
PAC
SACH 60H,0;
LACC 20H
SUB 21H
ADD 22H
SUB 23H
ADD 24H
ADD 60H
SUB 61H
ADD 62H
SUB 63H
SACL 70H
ADD #800H
SACL 00H
;
OUT 00H,1AH
IN 0,04H
B LOOP1
NOP
;
H:B H

SACH 60H,4

NOP

OBSERVATION:
IIR LOW PASS FILTER
Vin=
Gain= 20 log ( Vo/ Vin)
Frequency ( Hz )

Amplitude ( V )

( dB )

IIR BANDSTOP FILTER


Vin=
Gain= 20 log ( Vo/ Vin)
Frequency ( Hz )

OUTPUT:
IIR LOWPASS FILTER

Amplitude ( V )

( dB )

IIR BANDSTOP FILTER

RESULT:
Thus IIR filters have been implemented using DSP
processor.

You might also like