You are on page 1of 22

;

***********************************************************************
******
; INTERPOLATION
;
***********************************************************************
******
;PROGRAM DESCRIPTION:
; In this program the sampling rate is increased at the input by
;including zeros. The samples are taken at the lower sampling rate and
;since this program uses the interpolation factor of 4, three zeros are
;included after each sample taken from the adc. So the number of
samples
;and thus the sampling rate is also increased.

;* Approximation type: Window design - Rectangular Window


;* Filter type: Lowpass filter
;* Filter Order: 52
;* Cutoff frequency in KHz = 4.000000
.mmregs
.text
B START
CTABLE:
.word 0FF82H
.word 083H
.word 0167H
.word 01CFH
.word 0188H
.word 09DH
.word 0FF5BH
.word 0FE38H
.word 0FDACH
.word 0FE01H
.word 0FF31H
.word 0DEH
.word 0271H
.word 0342H
.word 02DDH
.word 0132H
.word 0FEADH
.word 0FC20H
.word 0FA92H
.word 0FAEEH
.word 0FDB6H
.word 02CCH
.word 096AH
.word 0104CH
.word 015F9H
.word 0192EH
.word 0192EH
.word 015F9H
.word 0104CH
.word 096AH
.word 02CCH
.word 0FDB6H
.word 0FAEEH
.word 0FA92H
.word 0FC20H
.word 0FEADH
.word 0132H
.word 02DDH
.word 0342H
.word 0271H
.word 0DEH
.word 0FF31H
.word 0FE01H
.word 0FDACH
.word 0FE38H
.word 0FF5BH
.word 09DH
.word 0188H
.word 01CFH
.word 0167H
.word 083H
.word 0FF82H
*
* 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
*
LAR AR0,#4H
ISR: LDP #0AH
LACC #0
SACL 0
OUT 0,05 ;pulse to find sampling frequency
MAR *,AR0
BANZ INC0,*-
IN 0,06H
; LAR AR7,#0 ;change value to modify sampling
freq.
; MAR *,AR7
;BACK: BANZ BACK,*-
RPT #10H
IN 0,4
LAR AR0,#4H
B STORE
INC0: SPLK #0H,0H
RPT #15H
NOP
STORE: 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
LAR AR1,#0300H
SACH * ;give as sach *,1 incase of overflow
LACC *
ADD #800H
SFR ;remove if o/p is less amplitude
SACL *
OUT *,4
LACC #0FFFH
SACL 0
OUT 0,05
NOP
B ISR
.end
;
**************************************************************************
**
; DECIMATION
;
**************************************************************************
**
;PROGRAM DESCRIPTION:
; In this program the sampling rate at the input is 35Khz. This
input
;sampling rate is reduced by a factor of 4 at the output. For this, the
;auxillary register AR0 is loaded with the value of 4 initially. Then the
;output of the FIR filter is sent out to the dac only once out of 4
outputs.
;i.e whenever the register AR0 becomes 0, the filter output is sent to the
;dac and reloaded with 4. where 4 is the decimation factor of this
decimator.
;
*
* Approximation type: Window design - Rectangular Window
* Filter type: Lowpass filter
* Filter Order: 52

* Cutoff frequency in KHz = 4.000000


.mmregs
.text
B START
CTABLE:
.word 0FF82H
.word 083H
.word 0167H
.word 01CFH
.word 0188H
.word 09DH
.word 0FF5BH
.word 0FE38H
.word 0FDACH
.word 0FE01H
.word 0FF31H
.word 0DEH
.word 0271H
.word 0342H
.word 02DDH
.word 0132H
.word 0FEADH
.word 0FC20H
.word 0FA92H
.word 0FAEEH
.word 0FDB6H
.word 02CCH
.word 096AH
.word 0104CH
.word 015F9H
.word 0192EH
.word 0192EH
.word 015F9H
.word 0104CH
.word 096AH
.word 02CCH
.word 0FDB6H
.word 0FAEEH
.word 0FA92H
.word 0FC20H
.word 0FEADH
.word 0132H
.word 02DDH
.word 0342H
.word 0271H
.word 0DEH
.word 0FF31H
.word 0FE01H
.word 0FDACH
.word 0FE38H
.word 0FF5BH
.word 09DH
.word 0188H
.word 01CFH
.word 0167H
.word 083H
.word 0FF82H
*
* 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
*
LAR AR0,#4H
ISR:
LDP #0AH
LACC #0
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
LAR AR1,#0300H
SACH * ;give as sach *,1 incase of overflow
LACC *
ADD #800H
SFR ;remove if o/p is less amplitude
SACL *
MAR *,AR0
BANZ NO_OUT,*-
MAR *,AR1
OUT *,4
LAR AR0,#4H
NO_OUT:
LACC #0FFH
SACL 0
OUT 0,05
NOP
B ISR
.end
>>pin sequence a=

0 1 1 1
0 0 1 1
0 0 0 1
1 0 0 0
0 1 0 0
0 0 1 0
1 0 0 1
1 1 0 0
0 1 1 0
1 0 1 1
0 1 0 1
1 0 1 0
1 1 0 1
1 1 1 0
1 1 1 1

Columns 1 through 9

14 12 8 1 2 4 9 3 6

Columns 10 through 15

13 10 5 11 7 15

output sequence

1 0 1 0 1 1

Columns 1 through 9

150 130 90 20 10 30 80 20 70

Columns 10 through 18

140 110 60 100 60 140 130 130 90

Columns 19 through 24

20 30 50 100 40 70
1 0 1 0 1 1

INPUT .set 8010H

BIT_REV .set 8020H

INPLACE .set 8030H

TWIDLE .set 8090H

PERIO .set 8040H

N .set 0H

STG .set 1H

STGC .set 3H

GRP .set 4H

GRPC .set 5H

BFLY .set 6H

BFLYC .set 7H

DNS .set 8H

DNSC .set 9H

.MMREGS

.TEXT

LDP #100H

CALL FFT

LAR AR0,#8030H

LAR AR1,#PERIO

LACC 0H

SUB #1H

SACL 75H

LAR AR2,75H

START ZAP

MAR *,AR0
LT *

MPY *+

PAC

BSAR 0CH

SACL 65H

LT *

MPY *+,AR1

PAC

BSAR 0CH

ADD 65H

BSAR 4

AND #0FFFH

CALL 0B400H

MAR *,AR1

SACH *+,AR2

BANZ START,*-

H B H

FFT

LDP #100H

LACC N

CALL 0B000H

LAR AR0,#BIT_REV

LAR AR5,#INPLACE

CALL 0B100H

SPLK #3H,STG

SPLK #1H,BFLY

SPLK #2H,DNS

SPLK #2H,0FH
ZAP

LT 0FH

MPY N

SPL 2H

LT 2H

MPY STG

SPL 2H

LAR AR1,#TWIDLE

MAR *,AR1

RPT 2H

BLPD #TABLE,*+

LAR AR1,#TWIDLE

LACC STG

SUB #1H

SACL STGC

LACC 00

SACL GRP

LAR AR7,STGC

STGLOP LACC GRP

BSAR 1H

SACL GRP

SUB #1H

SACL GRPC

LAR AR6,GRPC

LACC BFLY

SUB #1H

SACL BFLYC

LACC DNS
SUB #1H

SACL DNSC

LAR AR0,#INPLACE

GRPLOP LAR AR2,BFLYC

BFLYLOP CALL 0B200H

MAR *,AR0

RPT DNSC

LACC *+

CALL 0B200H

MAR *,AR0

RPT DNSC

LACC *-

CALL 0B300H

MAR *,AR0

RPT DNSC

LACC *-

MAR *,AR2

BANZ BFLYLOP,*-

MAR *,AR0

RPT DNSC

LACC *+

MAR *,AR6

BANZ GRPLOP,*-

LT BFLY

MPY #2H

SPL BFLY

LT DNS

MPY #2H
SPL DNS

MAR *,AR7

BANZ STGLOP,*-

RET

TABLE

.word 00100H

.word 00000H

.word 00100H

.word 00000H

.word 00100H

.word 00000H

.word 00100H

.word 00000H

.word 00100H

.word 00000H

.word 00100H

.word 00000H

.word 00100H

.word 00000H

.word 00100H

.word 00000H

.word 00100H

.word 00000H

.word 00100H

.word 00000H

.word 00100H

.word 00000H

.word 00000H

.word 0FF00H

.word 00100H

.word 00000H
.word 00100H

.word 00000H

.word 00100H

.word 00000H

.word 00000H

.word 0FF00H

.word 00100H

.word 00000H

.word 00100H

.word 00000H

.word 00100H

.word 00000H

.word 000B5H

.word 0FF4BH

.word 00100H

.word 00000H

.word 00000H

.word 0FF00H

.word 00100H

.word 00000H

.word 0FF4BH

.word 0FF4BH

.END
% DIRECT SEQUENCE SPREAD SPECTRUM:
clear;
a=pn;
d=[1 0 1 0 1 1];
ch=4;
h=1;
for i=1:6
for j=1:ch
k=ch*(i-1)+j;
if d(i)==a(1,4)
s(k)=0
else
s(k)=1
end;
h=h+1;
if h>15
h=1;
end;
end;
end;
h=1;
c1=si(-1);
c2=si(1);
len=length(c1);
for i=1:24
if s(i)==0
b1([len*(i-1)+h:i*len])=c1([1:len]);
else
b1([len*(i-1)+h:i*len])=c2([1:len]);
end;
end;
plot(b1);
title('Direct spread spectrum ');
xlabel('Time in seconds');
ylabel('Amplitude in Volts');
% AMPLITUDE MODULATION:

clc;
clear all;
close all;
am=2;
ac=4;
ka=am/ac;
fm=100;
t=0:0.01:50;
wm=(2*(3.14)*fm*t);
fc=1000;
wc=2*3.14*fc*t;
m=am*(sin(wm));
subplot(3,1,1);
plot(t,m);
title('Message Signal');
xlabel('Time in Seconds');
ylabel('Amplitude in volts');
c=ac*(sin(wc));
subplot(3,1,2);
plot(t,c);
title('Carrier Signal');
xlabel('Time in Seconds');
ylabel('Amplitude in volts');
lsb=(ka*ac/2)*(cos(wc-wm));
msb=(ka*ac/2)*(cos(wc+wm));
x=c+lsb-msb;
subplot(3,1,3);
plot(t,x);
title('Modulated Signal');
xlabel('Time in Seconds');
ylabel('Amplitude in volts');
% AMPLITUDE SHIFT KEYING:
E1=5;
E2=3;
f=3000;
t1=1:1:50;
t=100;
res1=sqrt(2*E1/t)*(cos((2*3.14*f*t1)+90));
t2=51:1:100;
res2=sqrt(2*E2/t)*(cos((2*3.14*f*t2)+90));
t=1:1:100;
result(1:50)=res1(1:50);
result(51:100)=res2(1:50);
figure(1);
plot(t,result);
title('AMPLITUDE SHIFT KEYING');
xlabel('Time in Seconds ---->');
ylabel('Amplitude in Volts---->');
grid on;
% FREQUENCY HOPPING SPREAD SPECTRUM:

clc;
clear all;
clear;
disp('pn sequence a = ');
d=[1 0 1 0 1 1];
ch=4;
s=pn;
disp(s);
for i=1:15
f(i)=0;
for j=1:4
f(i)=f(i)+s(i,j)*2^(j-1);
end;
end;
disp(f);
df=10;
k=1;
for i=1:length(d);
for j=1:ch
if d(i)==0
f0((i-1)*ch+j)=10*f(k)-df;
else
f0((i-1)*ch+j)=10*f(k)+df;
end;
k=k+1;
if k>15
k=1;
end;
end;
end;
disp('output sequence');

k=1;
for i=1:length(d)
for j=1:ch
df1(j)=f0((i-1)*ch+j)-10*f(k);
k=k+1;
if (k>15)
k=1;
end;
end;
if df1(1)>0&df1(2)>0
c(i)=1;
else
c(i)=0;
end;
end;
disp(d);
disp(f0);
disp(c);

You might also like