You are on page 1of 49

EXPERIMENT NO.

01
Aim: Write a program to print power of 2 from 20 to 212. Appratus Used: 8051 IDE Simulator Software, Proteus Professional. Program: 1)Snapshot of program in 8051 simulator:

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 1

2)LST File :

1 0000 2 0000 020030 3 0030 4 0030 7402 5 0032 75F002 6 0035 780C 7 0037 A4 8 0038 F5A0 9 003A 75F002 10 003D D8F8 11 003F Defined Symbols: Defined Labels: MAIN UP

ORG 0000H LJMP MAIN ORG 0030H MAIN:MOV A,#02H MOV B,#02H MOV R0,#12 UP: MUL AB MOV P2,A MOV B,#02H DJNZ R0,UP END

;Start at location 0 ;bypass interrupt vector table ;INT0 ISR ;send 02H to A ;send 02H to B ;initialize counter ;multiply value of A & B ;send value of A to port 2 ;send 02H to B ;decrement & jump on non-zero to up ;end of program.

000030 48 000037 55

Result:The power of 2 i.e. 20 to 212 is generated & printed.

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 2

EXPERIMENT NO. 02
Aim: Write a program that continuously reads port A and provides output to port B . Appratus Used: 8051 IDE Simulator Software, Proteus Professional. Program: 1)Snapshot of program in 8051 simulator:

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 3

2)LST File:
1 0000 2 0000 020030 3 0030 4 0030 759004 5 0033 75A000 6 0036 E590 7 0038 F5A0 8 003A 80FA 9 003C Defined Symbols: Defined Labels: MAIN UP ORG 0000H LJMP MAIN ORG 0030H MAIN:MOV P1,#04H MOV P2,#00H UP: MOV A,P1 MOV P2,A SJMP UP END ;Start at location 0 ;bypass interrupt vector table ;INT0 ISR ;send 04H to P1 ;send 00H to P2 ;send P1 to A ;send A to P2 ;short jump TO UP ; end of program.

000030 48 000036 54

Result:The program that reads the port A & provides that output to port B is performed.

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 4

EXPERIMENT NO. 03
Aim: Write a program that will read the data on all 8 bits of port B swap the nibble of data and send it to port A . Appratus Used: 8051 IDE Simulator Software, Proteus Professional. Program: 1)Snapshot of program in 8051 simulator:

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 5

2)LST File:
1 0000 2 0000 020030 3 0030 4 0030 759000 5 0033 75A0FF 6 0036 E5A0 7 0038 C4 8 0039 F590 9 003B 80F9 10 003D Defined Symbols: Defined Labels: MAIN UP ORG 0000H LJMP MAIN ORG 0030H MAIN:MOV P1,#00H MOV P2,#0FFH UP: MOV A,P2 SWAP A MOV P1,A SJMP UP END ;Start at location 0 ;bypass interrupt vector table ;INT0 ISR ;send 00H to P1 ;send 0FFH to P2 ;Move the data of P2 to A ;swap A ;move A to P1 ;short jump to UP ; end of program

000030 48 000036 54

Result:The program that reads the data from port B is generated & swapping is performed on that data & sent to port A.

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 6

EXPERIMENT NO. 04
Aim: Create a program that will turn on an LED when falling edge occur on external interrupt 0 & turn it off when rising edge occur on external interrupt 1. Appratus Used: 8051 IDE Simulator Software, Proteus Professional. Program: 1)Snapshot of program in 8051 simulator:

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 7

2)LST File:
1 0000 2 0000 020030 3 0003 4 0003 02003C 5 0013 6 0013 02003F 7 0030 8 0030 75A000 9 0033 75A885 10 0036 D288 11 0038 D28A 12 003A 80FE 13 003C D2A0 14 003E 32 15 003F C2A0 16 0041 32 17 0042 Defined Symbols: Defined Labels: ISRINT0 ISRINT1 MAIN ORG 0000H LJMP MAIN ORG 0003H LJMP ISRINT0 ORG 0013H LJMP ISRINT1 ORG 0030H MAIN:MOV P2,#00H MOV IE,#85H SETB TCON.0 SETB TCON.2 SJMP $ ISRINT0: SETB P2.0 RETI ISRINT1:CLR P2.0 RETI END ;Start at location 0 ;bypass interrupt vector table ;INT0 ISR ;INT1 ISR ;starting location for program ;send 00H to port 2 ;IE=01000101 enable external serial interrupt ;set INT0 interrupt ;set INT1 interrupt ;stay here until interrupted ;turn ON the LED(connected to P2.0)

;turn OFF the LED ;return from ISR ;end of program

00003C 60 00003F 63 000030 48

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 8

3) Snapshot of simulation in proteus:

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 9

4)Snapshot of simulation in proteus

Result:Program to turn off the LED on falling edge occur on external interrupt 0 & turn on LED on rising edge on interrupt 1 is written & verified using proteus software.

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 10

EXPERIMENT NO. 05 Aim: Create a program to output the ASCII character M energy 50ms via USART at 9600 baud rate . Appratus Used: 8051 IDE Simulator Software, Proteus Professional. Program: 1)Snapshot of program in 8051 simulator

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 11

2)LST File:
1 0000 2 0000 758920 3 0003 758DFD 4 0006 759850 5 0009 D28E 6 000B 7 000B 744D 8 000D F599 9 000F 3099FD 11 0012 C299 12 0014 1118 13 0016 80F3 14 0018 15 0018 758921 16 001B 758C3C 17 001E 758AB0 18 0021 D28C 19 0023 308DFD 20 0026 C28D 21 0028 22 22 0029 23 0029 Defined Symbols: Defined Labels: DELAY HERE LOOP NEXT ORG 0000H MOV TMOD,#20H MOV TH1,#-3 MOV SCON,#50H SETB TR1 LOOP:MOV A,#'M' MOV SBUF,A HERE:JNB TI,HERE CLR TI ACALL DELAY SJMP LOOP ; start at location 0 ; timer 1 mode 2 ;load the count value ;8bit 1 stop REN enable ;start timer1 ;copy letter M to accumulator ;letter M to be transferred ;wait for the last bit to transfer ;clear T1 for the next character ;generate delay ;go to send the character again

DELAY:MOV TMOD,#21H;timer 1 MOV TH0,#3cH ;for delay load the count MOV TL0,#0b0H SETB TR0 ;start timer 0 NEXT:JNB TF0,NEXT ;wait for TF 0 to roll over CLR TF0 ;clear timer flag0 RET ;return END ;end of program

000018 24 00000F 15 00000B 11 000023 35

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 12

3)Snapshot of simulation in proteus software:

Result:Program to provide output ASCII character M in every 50 ms via UARTat 9600 baud rate is written & verified using proteus software.

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 13

EXPERIMENT NO. 06

Aim: Write a program to transfer word CHHATTISGARH serially at 4800 baud rate and 1 stop bit,to the com port of PC continuously using LCD. Appratus Used: 8051 IDE Simulator Software, Proteus Professional. Program: 1)Snapshot of program in 8051 simulator:

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 14

2) LST File:
1 0000 ORG 00H ;start from location 0 2 0000 020030 LJMP MAIN ;allocate to interrupt vector table 3 0200 ORG 200H :start ISR 4 0200 43 48 48 DB 'CHHATTISGARH',0 0203 41 54 54 0206 49 53 47 0209 41 52 48 5 0030 ORG 0030H ;start ISR 6 0030 758000 MAIN: MOV P0,#00H ;send 00 to port 0 7 0033 75A000 MOV P2,#00H ;send 00 to port 2 8 0036 7438 MOV A,#38H ; move the 38H to A 9 0038 1164 ACALL CMD ;serial data transfer subroutine 10 003A 117E ACALL DELAY ;delay generation subroutine 11 003C 740C MOV A,#0CH ; move the 38H to A 12 003E 1164 ACALL CMD 13 0040 117E ACALL DELAY 14 0042 7406 MOV A,#06H ; move the 06H to A 15 0044 1164 ACALL CMD 16 0046 117E ACALL DELAY 17 0048 7401 MOV A,#01H ; move the 01H to A 18 004A 1164 ACALL CMD 19 004C 117E ACALL DELAY 20 004E 7480 MOV A,#80H ; move the 80H to A 21 0050 1164 ACALL CMD 22 0052 117E ACALL DELAY 23 0054 900200 MOV DPTR,#200H ;load data pointer 24 0057 E4 BACK:CLR A ;clear accumulator 25 0058 93 MOVC A,@A+DPTR;copy content of external ROM address formed by adding A+DPTR to A 26 0059 6007 JZ OUT ; jump with 0 to out 27 005B 1171 ACALL DATA 28 005D 117E ACALL DELAY 29 005F A3 INC DPTR ; increment data pointer 30 0060 80F5 SJMP BACK ;short jump to back 31 0062 80FE OUT:SJMP $ 32 0064 F580 CMD: MOV P0,A ; send A to port 0 33 0066 C2A0 CLR P2.0 ;clear port 2.0 34 0068 C2A1 CLR P2.1 ;clear port 2.1 Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 15

35 006A D2A2 36 006C 117E 37 006E C2A2 38 0070 22 39 0071 F580 40 0073 D2A0 41 0075 C2A1 42 0077 D2A2 43 0079 117E 44 007B C2A2 45 007D 22 46 007E 7832 47 0080 79FF 48 0082 D9FE 49 0084 D8FA 50 0086 22 Defined Symbols: Defined Labels: BACK CMD DATA DELAY H1 H2 MAIN OUT

SETB P2.2 ;set the bit port 2.2 ACALL DELAY CLR P2.2 ;clear port 2.2 RET ;return DATA: MOV P0,A ;send A to port 0 SETB P2.0 ;set port 2.0 CLR P2.1 ;clear port 2.1 SETB P2.2 ;set port 2.2 ACALL DELAY CLR P2.2 ; clear port 2.2 RET ;return DELAY: MOV R0,#32H ;initialize counter H2: MOV R1,#0FFH ;initialize counter H1:DJNZ R1,H1 ;if R1is not equal 0,repeat DJNZ R0,H2 ;if R0is not equal 0,repeat RET ;return

000057 87 000064 100 000071 113 00007E 126 000082 130 000080 128 000030 48 000062 98

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 16

3)Snapshot of simulation in proteus software:

Result:Program that transfer the word CHHATTISHGARH serially at 4800 baud rate is written & verified using proteus software.

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 17

EXPERIMENT NO. 07

Aim: Use external hardware interrupt to print a message to standard output device each time an interrupt occur .Also print the number of time interrupt occur. Appratus Used: 8051 IDE Simulator Software, Proteus Professional. Program: 1)Snapshot of program in 8051 simulator:

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 18

2) LST File:
1 0000 2 0000 020030 3 0200 4 0200 49 4E 54 0203 45 52 55 0206 50 54 00 5 0030 6 0030 758000 7 0033 75A000 8 0036 75A881 9 0039 D288 10 003B 7F30 11 003D 80FE 12 003F 0F 13 0040 BF3903 14 0043 7F30 15 0045 32 16 0046 758000 17 0049 75A000 18 004C 7438 19 004E 117A 20 0050 1194 21 0052 740C 22 0054 117A 23 0056 1194 24 0058 7406 25 005A 117A 26 005C 1194 27 005E 7401 28 0060 117A 29 0062 1194 30 0064 7480 31 0066 117A 32 0068 1194 33 006A 900200 34 006D E4 35 006E 93 36 006F 6007 ORG 00H LJMP MAIN ORG 200H DB 'INTERUPT',0 ;start at location 0 ;allocate to interrupt vector table

ORG 0030H MAIN: MOV P0,#00H MOV P2,#00H MOV IE,#81H SETB TCON.0 MOV R7,#30H HERE:SJMP HERE ISRINT0:INC R7 CJNE R7,#39H,N1 MOV R7,#30H RETI N1:MOV P0,#00H MOV P2,#00H MOV A,#38H ACALL CMD ACALL DELAY MOV A,#0CH ACALL CMD ACALL DELAY MOV A,#06H ACALL CMD ACALL DELAY MOV A,#01H ACALL CMD ACALL DELAY MOV A,#80H ACALL CMD ACALL DELAY MOV DPTR,#200H BACK:CLR A MOVC A,@A+DPTR JZ OUT

;configure P0 as an output port ;configure P2 as an output port ;enable the interrupt ;start timer 0 ;set the count value ;increment the value of R7 ;compare R7 value to 39H & iump with not equal to ;return interrupt routine ; configure P0 as an output port ; configure P0 as an output port ;load tha 38H to auumulator

;load tha 0CH to auumulator

;load tha 06H to auumulator

;load tha 01H to auumulator

;load tha 80H to auumulator

;initialize pointer for message ;clear auumulator ;get tha value ;jump with zero to out

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 19

37 0071 1187 38 0073 1194 39 0075 A3 40 0076 80F5 41 0078 80FE 42 007A F580 43 007C C2A0 44 007E C2A1 45 0080 D2A2 46 0082 1194 47 0084 C2A2 48 0086 22 49 0087 F580 50 0089 D2A0 51 008B C2A1 52 008D D2A2 53 008F 1194 54 0091 C2A2 55 0093 22 56 0094 7832 57 0096 79FF 58 0098 D9FE 59 009A D8FA 60 009C 22 Defined Symbols: Defined Labels: BACK CMD DATA DELAY H1 H2 HERE ISRINT0 MAIN N1 OUT

ACALL DATA ACALL DELAY INC DPTR SJMP BACK OUT:SJMP $ CMD: MOV P0,A CLR P2.0 CLR P2.1 SETB P2.2 ACALL DELAY CLR P2.2 R ET DATA: MOV P0,A SETB P2.0 CLR P2.1 SETB P2.2 ACALL DELAY CLR P2.2 RET DELAY: MOV R0,#32H H2: MOV R1,#0FFH H1:DJNZ R1,H1 DJNZ R0,H2 RET

;increment pointer

;move the data of accumulator to port 0 ;clear port 2.0 ;clear port 2.1 ;set port 2.2 ;clear port 2.2 ;return ; clear port 2.0 ; clear port 2.1 ; set port 2.2 ;clear port 2.2 ;return ; for delay generation

00006D 109 00007A 122 000087 135 000094 148 000098 152 000096 150 00003D 61 00003F 63 000030 48 000046 70 000078 120

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 20

3)Snapshot of simulation in proteus software:

Result:Program that print the message to standard output device each time an interrupt is occur is written and counted & verified using proteus software.

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 21

EXPERIMENT NO. 08

Aim: Write aMC 8051 program that generates 2khz square wave on pin P1.0,2.5khz on pin P1.2 and 25hz on pin P1.3. Appratus Used: 8051 IDE Simulator Software, Proteus Professional. Program: 1)Snapshot of program in 8051 simulator:

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 22

2) LST File:
1 0000 org 0000h 2 0000 020030 ljmp main 3 000B org 000bh 4 000B 020041 ljmp isrtimer0 5 001B org 001bh 6 001B 02004D ljmp isrtimer1 7 0030 org 0030h 8 0030 759000 main: mov p1,#00h 9 0033 758922 mov tmod, #22h 10 0036 75A88A mov IE,#8Ah 11 0039 7864 mov r0, #64h 12 003B 758C05 mov th0,#05h 13 003E 758D50 mov th1,#50h 14 0041 C28D isrtimer0:clr TF0 15 0043 B292 cpl p1.2 16 0045 B86404 cjne r0,#64h, m1 17 0048 B293 cpl p1.3 18 004A 7864 mov r0,#64h 19 004C 32 m1: reti 20 004D 21 004D C28F isrtimer1:clr TF1 22 004F B290 cpl p1.0 23 0051 32 reti 24 0052 25 0052 end Defined Symbols: Defined Labels: isrtimer0 isrtimer1 m1 main ;Start at location 0 ;allocate to interrupt vector table ;start ISR ;start ISR ;send 00H to P1(output) ;send 22H to TMOD(timer 0 & 1 mode 2 auto reload) ;interrupt enable ;send 64H to R0 ;send 05H to TH0 ;send 50H to TH1 ;clear TF0 ;compliment P1.2 ;compare &jump not equal to m1 ;compliment P1.3 ;send 64H to R0 ;return interrupt ;clear TF0 ;compliment P1.0 ;return interrupt ;end of program

000041 65 00004D 77 00004C 76 000030 48

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 23

3)Snapshot of simulation in proteus software:

Result:Program that that generates 2khz square wave on pin P1.0,2.5khz on pin P1.2 and 25hz on pin P1.3.is written & verified using proteus software.

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 24

EXPERIMENT NO. 09

Aim: Write a program to receive bytes of data serially and put them in P1. Set the baud rate at 2400 baud,8 bit data and 1 stop bit. Assume crystal frequency to be 11.092MHz.. Appratus Used: 8051 IDE Simulator Software, Proteus Professional. Program: 1)Snapshot of program in 8051 simulator:

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 25

2) LST File:
1 0000 2 0000 020030 3 0030 4 0030 758920 5 0033 758DF4 6 0036 759850 7 0039 D28E 8 003B 759000 9 003E 3098FD 10 0041 E599 11 0043 C298 12 0045 F590 13 0047 80F5 14 0049 Defined Symbols: Defined Labels: HERE MAIN ORG 00H LJMP MAIN ORG 0030H MAIN:MOV TMOD,#20H MOV TH1,#-12 MOV SCON,#50H SETB TR1 MOV P1,#00H HERE:JNB RI,HERE MOV A,SBUF CLR RI MOV P1,A SJMP HERE END ;start at location 0 ;allocate to interrupt vector table ;timer 1 mode 2 ;count for baud rate ;8 bit 1 stop bit REN enable ;start timer 1 ;port 1 as output ;wait for value ;move data to accumulator ;get ready to receive next byte ;move A to P1 ;continue receiving data ;end of program

00003E 62 000030 48

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 26

3)Snapshot of simulation in proteus software:

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 27

Result:Program that receive bytes of data serially and put them in P1 at baud rate at 2400 baud,8 bit data and 1 stop bit is written & verified using proteus software.

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 28

EXPERIMENT NO. 10

Aim: Write a program to transfer word communicationserially at 4800 baud & 1 stop bit to com port of PC continuously. Appratus Used: 8051 IDE Simulator Software, Proteus Professional. Program: 1)Snapshot of program in 8051 simulator:

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 29

2) LST File:
1 0000 2 0000 020030 3 0003 4 0200 5 0200 43 4F 4D 0203 4D 55 4E 0206 49 43 41 0209 54 49 4F 020C 4E 00 6 0030 7 0030 8 0030 758920 9 0033 758DFD 10 0036 759850 11 0039 D28E 12 003B 900200 13 003E E4 14 003F 93 15 0040 6005 16 0042 1149 17 0044 A3 18 0045 80F7 19 0047 80FE 20 0049 F599 21 004B 3099FD 22 004E C299 23 0050 22 24 0051 Defined Symbols: Defined Labels: BACK H1 MAIN OUT ORG 00H LJMP MAIN ORG 200H DB 'COMMUNICATION',0 ;start at location 0 ;allocate to interrupt vector table

ORG 0030H MAIN:MOV TMOD,#20H ;timer 1 mode 2 MOV TH1,#-3 ;load count value MOV SCON,#50H ;8 bit 1 stop bit REN enable SETB TR1 ;start timer 1 MOV DPTR,#200H ;initialize pointer for message BACK: CLR A;clear A MOVC A,@A+DPTR ;get the character JZ OUT ;jump with 0 to out ACALL TRANS INC DPTR ;increment pointer SJMP BACK OUT:SJMP $ TRANS:MOV SBUF,A ;load the data H1:JNB TI,H1 ;wait for complete byte transfer CLR TI ;get ready for next character RET ;return END ;end of program

00003E 62 00004B 75 000030 48 000047 71

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 30

3)Snapshot of simulation in proteus software:

Result:Program that transfer the word communicationserially at 4800 baud & 1 stop bit to com port of PC continuously is written & verified using proteus software

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 31

EXPERIMENT NO. 11

Aim: Write a MC 8051 program for counter 1 in mode 2 to count the pulses & display the state of the TL1 count on P2 .Assume that clock pulse are fed to pin T1. Appratus Used: 8051 IDE Simulator Software, Proteus Professional. Program: 1)Snapshot of program in 8051 simulator:

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 32

2) LST File:
1 0000 ORG 00H ;start at location 0 2 0000 020030 LJMP MAIN ;bypass the interrupt vector table 3 0030 ORG 0030H ;for subroutine 4 0030 758960 MAIN:MOV TMOD,#60H ;initialize the counter 5 0033 758D00 MOV TH1,#00H ;load the count value 6 0036 D2B5 SETB P3.5 ;set the pin p3.5 7 0038 D28E SETB TR1 ;start TR1 8 003A E58B BACK:MOV A,TL1 ;move the value of TL1 to A 9 003C F5A0 MOV P2,A ;send data of accumulator to P2 10 003E 308FF9 JNB TF1,BACK ;check timer 1 flag bit until its roll over 11 0041 C28F CLR TF1 ;clear TF1 12 0043 80F5 SJMP BACK ;repeat

Defined Symbols: Defined Labels: BACK MAIN

00003A 58 000030 48

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 33

3)Snapshot of simulation in proteus software:

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 34

Result:Program that count the pulses & display the count on P2 is written & verified using proteus software.

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 35

EXPERIMENT NO. 12

Aim: Write a MC 8051 program to measure the rpm & display it to the standard output device. Appratus Used: 8051 IDE Simulator Software, Proteus Professional. Program: 1)Snapshot of program in 8051 simulator:

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 36

2) LST File:
1 0000 2 0000 020030 3 0030 4 0030 758000 5 0033 75A000 6 0036 758961 7 0039 758D00 8 003C 758B00 9 003F D28E 10 0041 7814 11 0043 758C3C 12 0046 758AB0 13 0049 D28C 14 004B 308DFD 15 004E C28C 16 0050 C28D 17 0052 D8EF 18 0054 C28E 19 0056 C28F 20 0058 E58B 21 005A 75F03C 22 005D A4 23 005E 75F00A 24 0061 84 25 0062 ABF0 26 0064 75F00A 27 0067 84 28 0068 AAF0 29 006A F9 30 006B E9 31 006C 2430 32 006E F9 33 006F EA 34 0070 2430 35 0072 FA 36 0073 EB 37 0074 2430 38 0076 FB ORG 00H ;start at location 0 LJMP MAIN ;bypass interrupt vector table ORG 0030H MAIN: MOV P0,#00H ;send 00H to P0(output) MOV P2,#00H ; send 00H to P2(output) MOV TMOD,#61H ;intialise counter/ timer MOV TH1,#00 ROUND: MOV TL1,#00H SETB TR1 ;set TR1 MOV R0,#20 ;load count value BACK: MOV TH0,#3CH MOV TL0,#0B0H SETB TR0 HERE: JNB TF0,HERE ;for calculating rpm & lcd interface CLR TR0 CLR TF0 DJNZ R0,BACK CLR TR1 CLR TF1 MOV A,TL1 MOV B,#60 MUL AB MOV B,#0AH DIV AB MOV R3,B MOV B,#0AH DIV AB MOV R2,B MOV R1,A MOV A,R1 ADD A,#30H MOV R1,A MOV A,R2 ADD A,#30H MOV R2,A MOV A,R3 ADD A,#30H MOV R3,A

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 37

39 0077 7438 40 0079 11A7 41 007B 11BD 42 007D 740C 43 007F 11A7 44 0081 11BD 45 0083 7406 46 0085 11A7 47 0087 11BD 48 0089 7401 49 008B 11A7 50 008D 11BD 51 008F 7480 52 0091 11A7 53 0093 11BD 54 0095 E9 55 0096 11B2 56 0098 11BD 57 009A EA

MOV A,#38H ACALL CMD ACALL DELAY MOV A,#0CH ACALL CMD ACALL DELAY MOV A,#06H ACALL CMD ACALL DELAY MOV A,#01H ACALL CMD ACALL DELAY MOV A,#80H ACALL CMD ACALL DELAY MOV A,R1 ACALL DATA ACALL DELAY MOV A,R2

58 009B 11B2 ACALL DATA 59 009D 11BD ACALL DELAY 60 009F EB MOV A,R3 61 00A0 11B2 ACALL DATA 62 00A2 11BD ACALL DELAY 63 00A4 02003C LJMP ROUND 64 00A7 65 00A7 F580 CMD: MOV P0,A 66 00A9 C2A0 CLR P2.0 67 00AB D2A1 SETB P2.1 68 00AD 11BD ACALL DELAY 69 00AF C2A1 CLR P2.1 70 00B1 22 RET 71 00B2 72 00B2 F580 DATA: MOV P0,A 73 00B4 D2A0 SETB P2.0 74 00B6 D2A1 SETB P2.1 75 00B8 11BD ACALL DELAY 76 00BA C2A1 CLR P2.1 77 00BC 22 RET Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 38

78 00BD 79 00BD 7C32 80 00BF 7DFF 81 00C1 DDFE 82 00C3 DCFA 83 00C5 22 84 00C6 Defined Symbols: Defined Labels: BACK CMD DATA DELAY H1 H2 HERE MAIN ROUND

DELAY: MOV R4,#32H H2: MOV R5,#0FFH H1: DJNZ R5,H1 DJNZ R4,H2 RET END

;subroutine for delay generation

;return ;end of program

000043 67 0000A7 167 0000B2 178 0000BD 189 0000C1 193 0000BF 191 00004B 75 000030 48 00003C 60

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 39

Program:
ORG 00H LJMP MAIN ORG 0030H MAIN: MOV P0,#00H MOV P2,#00H MOV TMOD,#61H MOV TH1,#00 ROUND: MOV TL1,#00H SETB TR1 MOV R0,#20 BACK: MOV TH0,#3CH MOV TL0,#0B0H SETB TR0 HERE: JNB TF0,HERE CLR TR0 CLR TF0 DJNZ R0,BACK CLR TR1 CLR TF1 MOV A,TL1 MOV B,#60 MUL AB MOV B,#0AH DIV AB MOV R3,B MOV B,#0AH DIV AB MOV R2,B MOV R1,A MOV A,R1 ADD A,#30H MOV R1,A MOV A,R2 ADD A,#30H MOV R2,A MOV A,R3 Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 40

ADD A,#30H MOV R3,A MOV A,#38H ACALL CMD ACALL DELAY MOV A,#0CH ACALL CMD ACALL DELAY MOV A,#06H ACALL CMD ACALL DELAY MOV A,#01H ACALL CMD ACALL DELAY MOV A,#80H ACALL CMD ACALL DELAY MOV A,R1 ACALL DATA ACALL DELAY MOV A,R2 ACALL DATA ACALL DELAY MOV A,R3 ACALL DATA ACALL DELAY LJMP ROUND CMD: MOV P0,A CLR P2.0 SETB P2.1 ACALL DELAY CLR P2.1 RET DATA: MOV P0,A SETB P2.0 SETB P2.1 ACALL DELAY CLR P2.1 RET Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 41

DELAY: MOV R4,#32H H2: MOV R5,#0FFH H1: DJNZ R5,H1 DJNZ R4,H2 RET END

3)Snapshot of simulation in proteus software:

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 42

Result:Program that measure the rpm & display it to the standard device is written & verified using proteus software.

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 43

EXPERIMENT NO. 13

Aim: Write a MC 8051 program to simulate a engine speed motor that will light a LED if the motor speed drops below 200 rpm & another LED if motor speed exceed 500 rpm & light another LED if motor speed between 200 to 500 rpm.

Appratus Used: 8051 IDE Simulator Software, Proteus Professional. Program: 1)Snapshot of program in 8051 simulator:

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 44

2) LST File:
1 0000 ORG 00H ;start at location 0 2 0000 020030 LJMP MAIN ;bypass interrupt vector table 3 0030 ORG 0030H 4 0030 75A000 MAIN: MOV P2,#00H ;set P2 as output port 5 0033 D2B5 SETB P3.5 ;set pin P3.5 6 0035 758961 MOV TMOD,#61H ;initialize counter 7 0038 758D00 MOV TH1,#00 8 003B 758B00 AGAIN:MOV TL1,#00 ;reset TL1 to 00H 9 003E D28E SETB TR1 ;set TR1 10 0040 7814 MOV R0,#20 11 0042 12 0042 758C3C BACK: MOV TH0,#3CH 13 0045 758AB0 MOV TL0,#0B0H 14 0048 D28C SETB TR0 15 004A 308DFD HERE: JNB TF0,HERE ;compare the rpm value 16 004D C28C CLR TR0 17 004F C28D CLR TF0 18 0051 D8EF DJNZ R0,BACK 19 0053 E58B MOV A,TL1 20 0055 B40400 CJNE A,#04H,M1 21 0058 400D M1: JC M2 22 005A B40900 CJNE A,#09H,M3 23 005D 4010 M3: JC M4 24 005F C2A0 CLR P2.0 ;for red LED glow 25 0061 C2A1 CLR P2.1 26 0063 D2A2 SETB P2.2 27 0065 80D4 SJMP AGAIN 28 0067 C2A1 M2: CLR P2.1 ;for green LED glow 29 0069 C2A2 CLR P2.2 30 006B D2A0 SETB P2.0 31 006D 80CC SJMP AGAIN 32 006F C2A0 M4: CLR P2.0 ;for yellow LED glow 33 0071 C2A2 CLR P2.2 34 0073 D2A1 SETB P2.1 35 0075 80C4 SJMP AGAIN

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 45

Defined Symbols: Defined Labels: AGAIN BACK HERE M1 M2 M3 M4 MAIN

00003B 59 000042 66 00004A 74 000058 88 000067 103 00005D 93 00006F 111 000030 48

Program:
ORG 00H LJMP MAIN ORG 0030H MAIN: MOV P2,#00H SETB P3.5 MOV TMOD,#61H MOV TH1,#00 AGAIN:MOV TL1,#00 SETB TR1 MOV R0,#20 BACK: MOV TH0,#3CH MOV TL0,#0B0H SETB TR0 HERE: JNB TF0,HERE CLR TR0 CLR TF0 DJNZ R0,BACK MOV A,TL1 CJNE A,#04H,M1 M1: JC M2 CJNE A,#09H,M3 M3: JC M4 CLR P2.0 CLR P2.1 SETB P2.2 Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 46

SJMP AGAIN M2: CLR P2.1 CLR P2.2 SETB P2.0 SJMP AGAIN M4: CLR P2.0 CLR P2.2 SETB P2.1 SJMP AGAIN

3)Snapshot of simulation in proteus software:

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 47

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 48

Result:Program that light the different LED according to rpm values is written & verified using proteus software.

Embedded Technology In Communication System laboratory [Renu Verma. Roll No.5035112006] Page 49

You might also like