A_Lab_Report_on

81
A Lab Report on DIGITAL SYSTEMS LAB - I Submitted in partial fulfillment of the requirement for the award of degree of MASTERS IN ENGINEERING (DIGITAL SYSTEMS ENGINEERING) IN ELECTRONICS AND COMMUNICATION ENGINEERING BY KEESARI ABHIMANYU 1005-14-749108 2014-15 Department of Electronics and Communication Engineering University College of Engineering (Autonomous) Osmania University 1

description

jljklllllffffffffffffffrryyyyyyyyyyyyy

Transcript of A_Lab_Report_on

A Lab Report onDIGITAL SYSTEMS LAB - ISubmitted in partial fulfillment of the requirement for the award of degree of MASTERS IN ENGINEERING (DIGITAL SYSTEMS ENGINEERING)INELECTRONICS AND COMMUNICATION ENGINEERINGBYKEESARI ABHIMANYU1005-14-749108

2014-15Department of Electronics and Communication EngineeringUniversity College of Engineering (Autonomous)Osmania UniversityHyderabad-500007

ContentsPart - I1.Addition of ten natural numbers42.Count number of 1s in a byte53.Movement of data in RAM with increment by 264.Average75.Maximum86.BCD to 7-Segment Conversion97.Square Wave generation without interrupt108.Square Wave generation with interrupt119.Program to receive serial data without interrupt1210.Program to receive Serial data using interrupt1311.Program to transmit letter Y without interrupt1412.Program to transmit letter Y using interrupt1513.Program to transmit String serially1614.Temperature sensor17Part-II1. Linear Convolution202. Fast Fourier Transform213. Butterworth low pass filter224. Butterworth high pass filter design245. Butterworth band pass filter266. Chebyshev type I low pass filter287. Chebyshev type I High pass filter308. Chebyshev type I Band pass filter329. Chebyshev type I band stop filter3410. FIR low pass filter design3612. FIR High pass filter design3813. FIR Band pass filter design4014. FIR Band stop filter design4215. FIR low pass filter design using rectangular window4416. FIR low pass filter design using hamming window4617. FIR low pass filter design using triangular window4818. FIR high pass filter design using rectangular window5019. FIR high pass filter design using hamming window5220. FIR high pass filter design using triangular window5421. FIR band pass filter design using rectangular window5622. FIR band pass filter design using hamming window5823. FIR band stop filter design using triangular window6024. FIR band stop filter design using rectangular window6225. FIR band stop filter design using hamming window6426. FIR band stop filter design using triangular window66

1. Addition of ten natural numbersAim: To add first ten natural numbers and store the resultProgram:name addnaturalcount EQU 0x0Aresult EQU 0x50org 0000hMOV R1,#0x01;first natural no.MOV R0,#0x0A;count of tenMOV A,#0x00;clear ACCCLR C;clear Carryl1: ADDC A,R1;Add R1 and Acc with CINC R1;next no.DJNZ R0,l1;loop for 10 timesMOV result,A;store resultl2: SJMP l2endResult:First ten natural numbers sum = = 55 = 0x37

2. Count number of 1s in a byteAim: To count number of 1s in a given byteProgram:name count1sop1 EQU 0xF0result EQU 0x50org 0000hMOV A, #op1;store operand in AccMOV R1,#08;8 bits in abyteMOV R0,#00;count of 1'sl3:RLC A;Rotate Acc with CarryJNC l2;if C is setINC R0;increment l2: DJNZ R1,l3;loop 8 timesMOV result,R0 ;store resultl1: SJMP l1endResult:Operand is 0xF0 = 11110000No. of ones = 4

3. Movement of data in RAM with increment by 2Aim: To move 10 bytes of data from RAM at starting location 45H to 70H after adding 2 to each byteProgram:name movedatasrcaddr EQU 0x45dstaddr EQU 0x70count EQU 0x0Aorg 0000hMOV R0, #srcaddr;source addr pointerMOV R1, #dstaddr;destination addr pointerMOV R2, #count;no. of bytes to movel1: MOV A,@R0;read byte from sourceINC A;add 2INC AMOV @R1,A;write data to destinationINC R0;increment source addr pointerINC R1;increment destination addr pointerDJNZ R2,l1;loop for 10 times l2: SJMP l2end Result:Source data: 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0AAdding two to each byteDestination data: 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C

4. AverageAim: To find average of 6 subjects marks secured by a student in exam, located from address 0x45 of RAMProgram:name markslen EQU 0x06average EQU 0x50loc EQU 0x045org 0000hMOV R0,#loc ; pointer to marksMOV R1,#len ; count of 6MOV R2,#00 ; intermediate sumCLR Cl1:MOV A,@R0 ; converting BCD to HexADDC A,R2 ; Marks additionMOV R2,A ; intermediate sumINC R0 ; increment pointerDJNZ R1,l1 ; loop 6 timesMOV A,R2 ; R2 contains final sumMOV B,#lenDIV AB ;finding AverageMOV average,A; Store resulth1: SJMP h1 end

Result:Let the marks obtains be 21 22 23 24 25 26So in hex marks will be 0x15 0x16 0x17 0x18 0x19 0x19So the average is 0x17In decimal 23 (fraction ignored)

5. MaximumAim: To find maximum number in a given 10 bytes of data located from 0x50 location of RAM and store it at 0x60Program:name maxara1 EQU 0x50max EQU 0x60len EQU 0x0Aorg 0000hMOV R0,#ara1 ;pointer to dataMOV R1,#len;count of 10 no.MOV R2,#00;holds max bytel2:MOV A,@R0;fetching first byteINC R0CLR CMOV R3,ASUBB A,R2;if current byte is bigggerJC l1;jump to l1MOV A,R3;else update R2 MOV R2,Al1:DJNZ R1,l2MOV max,R2;R2 will have maximumh1:SJMP h1endResult:Assume that data is 0x10 0x20 x020 x50 0x60 0x20 0x30 0x15 0x14 0x01Then maximum is 0x60

6. BCD to 7-Segment ConversionAim: To convert a 2 digit BCD number to 7-segment code Program:name bcdtosegDIG EQU 0x23DIG1SEG EQU 0x50DIG2SEG EQU 0x51org 0000hMOV A,#DIGANL A,#0x0F;separating digit 1MOV DPTR,#tab;Equivalent data from LUTMOVC A,@A+DPTRMOV DIG2SEG,AMOV A,#DIG;separating digit 2ANL A,#0xF0SWAP AMOV DPTR,#tab;Equivalent data from LUTMOVC A,@A+DPTRMOV DIG1SEG,Ah1:SJMP h1tab: db 0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7C,0x07,0x7F,0x67endResult:Let the number be 0x23So first digit is 0x02 and second digit is 0x03. So their equivalent 7-segment code is 0x5B, 0x4F

7. Square Wave generation without interruptAim: To generate a square wave of frequency 1KHz at P1.0 without interruptProgram:name sqrwaveorg 0000hSJMP startstart:MOV P1,#00l1:MOV R0,#0xE6l2:DJNZ R0,l2; delay equavivalent to 500usCPL P1.0; Square waveSJMP l1end Results:

8. Square Wave generation with interruptAim: To generate a square wave of frequency 1KHz at P1.0 with interruptProgram:name sqrwaveintorg 0000hSJMP startorg 000Bh;Timer 0 ISRMOV TH0,#0xFEMOV TL0,#0x36CPL P1.0RETIstart:MOV P1,#00MOV TMOD,#0x01MOV IE,#0x82;Timer interrupt enableMOV TH0,#0xFE;Timer value loaded to generate 500usMOV TL0,#0x33SETB TR0l1:SJMP l1end

Result:

9. Program to receive serial data without interruptAim: To receive data serially at 9600 baud rate without interruptProgram:name uartrxorg 0000hsjmp startstart:MOV SCON,#0x50MOV TMOD,#0x20MOV TH1,#0xFD;9600 baud rate setting SETB TR1l1:JNB RI, l1;wait to receive flag setCLR RIMOV A,SBUF;Receive dataMOV P0,A; transmit to P0MOV SBUF,A;transmit to serial portl2:JNB TI,l2CLR TISJMP l1end

Result:

10.Program to receive Serial data using interruptAim: To receive data serially at 9600 baud rate using interruptProgram:name uartrxintorg 0000hSJMP startorg 0023h;Serial interrupt ISRJB TI,txintCLR RIMOV A,SBUF;Receiving byte MOV P0,A;moving received byte to P0MOV SBUF,A;Transmitting received byte seriallyRETItxint:CLR TIRETIstart:MOV SCON,#0x50;UART configuration to 9600 bpsMOV TMOD,#0x20MOV TH1,#0xFDMOV IE,#0x90SETB TR1l1:SJMP l1endResult:

11.Program to transmit letter Y without interruptAim: To transmit letter Y serially at 9600 baud rateProgram:name uarttxorg 0000hSJMP startstart:MOV SCON,#0x50;configuring serial port to 9600 bps MOV TMOD,#0x20MOV TH1,#0xFDSETB TR1l2:MOV A,#'Y'MOV SBUF,A;transmitting letter Yl1:JNB TI,l1CLR TISJMP l2endResult:

12.Program to transmit letter Y using interruptAim: To transmit letter Y serially at 9600 baud rate using interruptProgram:name uarttxintorg 0000hSJMP startorg 0023h;serial port ISRCLR TIMOV SBUF,#'Y';transmitting letter YRETIstart:MOV SCON,#0x50;serial port configuration to 9600bpsMOV TMOD,#0x20MOV TH1,#0xFDMOV IE,#0x90SETB TR1SETB TIl1:SJMP l1endResult:

13.Program to transmit String seriallyAim: To transmit EMVLSID serially at 9600 baud rateProgram:name uarttxorg 0000hSJMP startstart:MOV SCON,#0x50;configuring UART to 9600 bpsMOV TMOD,#0x20MOV TH1,#0xFDSETB TR1l2:MOV DPTR,#string1;loading starting address of stringl3:CLR AMOVC A,@A+DPTRCJNE A,#'0',pro;checking for end of string 0SJMP l2pro:MOV SBUF,A;transmitting each letterl1:JNB TI,l1CLR TIINC DPTRSJMP l3string1: db 'E','M','V','L','S','I','D','0'endResult:

14.Temperature sensorAim: Assume thatP1 is input port connected to a temperature sensor. Write a program to read the temperature and test it for the value 75. According to the test results, place temp value into the registers indicated by the followingIf T=75; then A=75; If T75; then R2=TProgram:name tempreadorg 0000hMOV P1,#0xFF;making P1 input portMOV A,P1;Read P1CJNE A,#0x75,l1;If P1 !=75, jump to L1here:SJMP here;else A=P1l1:JNC l2;If P1>75 jump to L2MOV R1,A;else R1=P1CLR ASJMP herel2:MOV R2,A;R2=P1CLR Ahere1:SJMP here1Result:IF T=0x75

IF T>75

IF T