0% found this document useful (0 votes)
80 views22 pages

Org 0000H LJMP Start Org 0100H Mov P2,#0Ffh Lcall Delay Mov P2,#00H Lcall Delay SJMP Start Mov R0,#100 DJNZ $ Ret End

The document contains several programs for controlling LEDs, generating waves, communicating with a PC through serial communication, and controlling an LCD display. The programs utilize timers, interrupts, and I/O ports to blink LEDs, generate waves, receive/transmit serial data, and display text on an LCD screen. Software delays, timer delays, and interrupt handling are used to control the timing of operations.

Uploaded by

Kesari Bai
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views22 pages

Org 0000H LJMP Start Org 0100H Mov P2,#0Ffh Lcall Delay Mov P2,#00H Lcall Delay SJMP Start Mov R0,#100 DJNZ $ Ret End

The document contains several programs for controlling LEDs, generating waves, communicating with a PC through serial communication, and controlling an LCD display. The programs utilize timers, interrupts, and I/O ports to blink LEDs, generate waves, receive/transmit serial data, and display text on an LCD screen. Software delays, timer delays, and interrupt handling are used to control the timing of operations.

Uploaded by

Kesari Bai
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

1(a) Blink LEDS on and off using software delay Label Assembly Source ORG 0000h LJMP START

ORG 0100h START : MOV P2,#0FFh LCALL DELAY MOV P2,#00h LCALL DELAY SJMP START MOV R0,#100 DJNZ $ RET END

DELAY :

1(b) Blink LEDS on and off alternately using software delay

Label

Assembly Source ORG 0000h LJMP START ORG 0100h

START :

MOV P2,#55h LCALL DELAY MOV P2,#0AAh LCALL DELAY SJMP START MOV R0,#100 DJNZ $ RET END

DELAY:

1(c) Blink lower and upper nibble using software delay Label Assembly Source ORG 0000h LJMP START ORG 0100h START : MOV P2,#80h LCALL DELAY MOV P2,#01h LCALL DELAY SJMP START MOV R0,#100 DJNZ $ RET END

DELAY :

1(d) Cyclic rotation of bit using software delay Label Assembly Source ORG 0000h LJMP START ORG 0100h START : REP : MOV A,#01h MOV P1,A LCALL DELAY RL A SJMP REP MOV R0,#100 DJNZ DELAY RET END

DELAY :

1(e) Triangular wave generation

Label

Assembly Source ORG 0000h LJMP START ORG 0100h MOV A,#00h MOV P2,A INC A CJNE A,#0FFh,START1 MOV A,#0FFh MOV P2,A DNC A CJNE A,#00h,REP SJMP START END

START : START1 :

REP :

1(f) Sine wave generation

Label

Assembly Source ORG 0000h LJMP START ORG 0300h DB:129,130,131,132..150,149.129 ORG 0100h

LOOKUP :

START :

MOV R0,#49 MOV DPTR,#0300h CLR A MOVC A,@A+DPTR MOV P2,A INC DPTR DJNZ R0,R LJMP START END

R:

2(a) Implement the LED blink program using hardware delay of 1sec duration. Use timer in 16 bit mode Label Assembly Source ORG 0000h LJMP START ORG 0100h MOV P1,#0FFh LCALL DELAY SJMP START MOV R0,A MOV A,#20 MOV TL0,#0FDh MOV TH0,#4Bh MOV TMOD,#01h CLR TF0 SETB TR0 JNB TFO,$ DJNZ R0,REP RET END

START :

DELAY : REP :

2(b) Implement the rotating LED program with incremental delay in steps of 200ms using timer 0 in 16 bit mode

Label

Assembly Source ORG 0000h LJMP START ORG 0100h MOV R3,#01h MOV A,#01h MOV P1,A LCALL DELAY RL A INC R3 CJNE R3,#08,REP1 SJMP START MOV 23h,R3 MOV R0,#04h MOV TL0,#0FDh MOV TH0,#4Bh MOV TMOD,#01h CLR TF0 SETB TR0 JNB TFO,$ DJNZ R0,REP DJNZ 23h,REP2 RET END

START :

REP1:

DELAY : REP2 : REP :

2(c) generate rectangular wave with 75% duty cycle for a frequency output of 10khz

Label

Assembly Source ORG 0000h LJMP START ORG 0100h

START :

MOV P1,#0FFh MOV A,#03h LCALL DELAY MOV P1,#00h MOV A,#01h LCALL DELAY SJMP start MOV R0,A MOV A,#20 MOV TL0,#0FDh MOV TH0,#4Bh MOV TMOD,#01h CLR TF0 SETB TR0 JNB TFO,$ DJNZ R0,REP RET END

DELAY : REP :

3a) Transmit the constant string of WELCOME TO EIE with a bard rate of 9600 from microcontroller to PC. Verify the output in PC using hyper terminal software. Add carriage return & line feed at the end of each transmission. Label Assembly Source ORG 0000h LJMP MAIN ORG 0200h WELCOME TO EIE ORG 0100h MOV SCON,#50h MOV TMOD,#21h MOV TL1,#253 MOV TH1,#253 SETB TR1 MOV DPTR,#0200h MOV R0,#14 CLR A MOVC A,@A+DPTR LCALL SENDSERIAL INC DPTR DJNZ R0,REP LCALL DELAY MOV A,#0Ah LCALL SENDSERIAL MOV A,#00h LCALL SENDSERIAL SJMP Cont

My data DB :

MAIN :

Cont :

REP :

SENDSERIAL: CLR TI MOV SBUF,A JNB TI,$ RET DELAY : REP1 : MOV R1,#05h MOV TL0,#0FDh MOV TH0,#4Bh CLR TF0 SETB TR0 JNB TF0,$ DJNZ R1,REP1 RET END

3b) Design a PC based home automation for following command from PC. Perform the function S.NO 1 2 3 4 Label COMMAND 0x31 0x32 0x33 0x34 Assembly Source ORG 0000h LJMP START ORG 0100h LCALL Initserial LCALL Receiveserial CJNE A,#31h,P1.1off SETB P1.1 SJMP EXIT CJNE A,#32h,P1.0on CLR P1.1 SJMP EXIT CJNE A,#33h,P1.0off SETB P1.0 SJMP EXIT CJNE A,#34h,EXIT CLR P1.0 MOV SCON,#50h MOV TMOD,#21 MOV TL1,#253 MOV TH1,#253 SETB TR1 RET JNB RI,$ MOV A,SBUF CLR RI RET SJMP START END OPERATION P1.1 ON P1.1 OFF P1.0 ON P1.0 OFF

START :

P1.1off:

P1.0on:

P1.0off:

Initserial:

Receiveserial:

Exit:

4(a) Timer 0 interrupt to generate a square wave at frequency of 10 khz at port 1.1 Label Assembly Source ORG 0000h LJMP MAIN ORG 0003h Isr : INC R1 CJNE R1,#05,NEXT CPL P2.1 MOV R0,#00 RETI ORG 0100h SETB EA SETB EX0 ETB IT0 SETB P2.0 LCALL DELAY CLR P2.0 LCALL DELAY SJMP REP MOV R0,#20 MOV TL0,#0FDh MOV TH0,#4Bh MOV TMOD,#01h CLR TF0 SETB TR0 JNB TF0,$ DJNZ R0,LOOP RET END

NEXT :

MAIN :

REP :

DELAY : LOOP :

4(b) Use external interrupt 0 to count no of times a push button is pressed by the user and complement port 1.1 Label Assembly Source ORG 0000h LJMP MAIN ORG 000Bh CLR TF0 CPL P1.1 RETI ORG 0100h SETB EA SETB EX0 SETB P1.1 LCALL DELAY SJMP REP MOV TL0,#0FDh MOV TH0,#4Bh MOV TMOD,#01h SETB TR0 JNB TF0,$ RET END

MAIN :

REP :

DELAY :

4(c) Use serial interrupt to receive data from pc at 9600 bard and update the received data at p1. Label Assembly Source ORG 0000h LJMP MAIN ORG 0023h MOV P2,SBUF CLR R2 RETI ORG 0100h SETB EA SETB EX0 SETB IT0 LCALL Initserial CPL P2.7 SJMP REP MOV SCON,#50h MOV TMOD,#12h MOV TL0,#253 MOV TH0,#253 SETB TR0 RET MOV R0,#20 MOV TL0,#0FDh MOV TH0,#4Bh MOV TMOD,#01h CLR TF0 SETB TR0 JNB TF0,$ DJNZ R0,LOOP RET END

MAIN :

REP :

Initserial:

DELAY : LOOP :

5(a) Write a program to display DEPARTMENT OF EIE on LCD display as : DEPARTMENT OF EIE

Label ORG 0000h LJMP main ORG 0050h LCDCMD: LINE1: LINE2:

Assembly Source

DB 38h,0Eh,06h,01h,82h DB DEPARTMENT OF DB EIE RS EQU P2.0 RW EQU P2.1 EN EQU P2.2 ORG 0100h LCALL Initlcd MOV A,#82h LCALL Sendlcdcmd MOV R0,#13 CLR A MOV DPTR,#LINE1 MOVC A,@A+DPTR LCALL Sendlcddata INC DPTR CLR A DJNZ R0,rep1 MOV A,#0C7h LCALL Sendlcdcmd MOV R0,#03h CLR A MOV DPTR,#LINE2 MOVC A,@A+DPTR LCALL Sendlcddata INC DPTR CLR A DJNZ R0,REP2 SJMP $

MAIN :

REP1 :

LOOP :

REP2 :

Initlcd :

CLR A MOV R0,#05 MOV DPTR,#LCDCMD MOVC A,@A+DPTR LCALL Sendlcdcmd INC DPTR CLR A DJNZ R0,REPEAT SETB RS CLR RW MOV P1,A LCALL DELAY CLR EN RET CLR RS CLR RW MOV P1,A SETB EN LCALL DELAY CLR EN RET END

REPEAT :

Sendlcddata:

Sendlcdcmd:

5(b) Write a program to display DEPARTMENT OF EIE on LCD display as : DEPARTMENT OF EIE And to blink EIE Label Assembly Source ORG 0000h LJMP MAIN ORG 0050h DB 38h,0Eh,06h,01h,82h DB DEPARTMENT OF DB EIE DB RS EQU P2.0 RW EQU P2.1 EN EQU P2.2 ORG 0100h LCALL Initlcd MOV A,#82h LCALL Sendlcdcmd MOV R0,#13 CLR A MOV DPTR,#LINE1 MOVC A,@A+DPTR LCALL Sendlcddata INC DPTR CLR A DJNZ R0,REP1 MOV A,#0C7h LCALL Sendlcdcmd MOV R0,#03h CLR A MOV DPTR,#LINE2 MOVC A,@A+DPTR LCALL Sendlcddata INC DPTR CLR A DJNZ R0,REP2 MOV R2,#30

LCDCMD: LINE1: LINE2: LINE3:

MAIN :

REP1 :

LOOP1 :

REP2 :

LCALL DELAY MOV A,#0C7h LCALL Sendlcdcmd MOV R0,#03h CLR A MOV DPTR,#LINE3 REP3 : MOVC A,@A+DPTR LCALL Sendlcddata INC DPTR CLR A DJNZ R0,REP3 MOV R2,#15 LCALL DELAY SJMP LOOP1 MOV A,R2 MOV R3,A MOV TL0,#0FDh MOV TH0,#4Bh MOV TMOD,#01h CLR TF0 SETB TR0 JNB TR0,$ DJNZ R3,LOOP CLR A MOV R0,#05 MOV DPTR,#LCDCMD MOVC A,@A+DPTR LCALL Sendlcdcmd INC DPTR CLR A DJNZ R0,REPEAT SETB RS CLR RW MOV P1,A LCALL DELAY CLR EN RET CLR RS CLR RW

DELAY :

LOOP :

Initlcd:

REPEAT:

Sendlcddata:

Sendlcdcmd:

MOV P1,A SETB EN LCALL DELAY CLR EN RET END

5(c) Write a program to display DEPARTMENT OF EIE on LCD display as : DEPARTMENT OF EIE And scroll EIE Label Assembly Source ORG 0000h LJMP MAIN ORG 0050h DB 38h,0Eh,06h,01h,82h DB DEPARTMENT OF DB EIE RS EQU P2.0 RW EQU P2.1 EN EQU P2.2 ORG 0100h LCALL Initlcd MOV A,#82h LCALL Sendlcdcmd MOV R0,#13 CLR A MOV DPTR,#LINE1 MOVC A,@A+DPTR LCALL Sendlcddata INC DPTR CLR A DJNZ R0,rep1 MOV R4,#0C0h MOV A,R4 LCALL Sendlcdcmd MOV R0,#03h CLR A MOV DPTR,#LINE2 MOVC A,@A+DPTR LCALL Sendlcddata INC DPTR CLR A DJNZ R0,REP2 MOV R2,#30

LCDCMD: LINE1: LINE2:

MAIN :

REP1 :

LOOP5 : LOOP4 :

REP2 :

LCALL DELAY MOV A,R4 LCALL Sendlcdcmd MOV A,# LCALL Sendlcddata INC R4 CJNE R4,#0CFh,LOOP4 SJMP LOOP5 Initlcd: CLR A MOV R1,#05 MOV DPTR,#LCDCMD MOVC A,@A+DPTR LCALL Sendlcdcmd INC DPTR CLR A DJNZ R1,REPEAT SETB RS CLR RW MOV P1,A LCALL DELAY CLR EN RET CLR RS CLR RW MOV P1,A SETB EN LCALL DELAY CLR EN RET MOV A,R2 MOV R3,A MOV TL0,#0FDh MOV TH0,#4Bh MOV TMOD,#01h CLR TF0 SETB TR0 JNB TF0,$ DJNZ R3,LOOP RET END

REPEAT :

Sendlcddata:

Sendlcdcmd:

DELAY :

LOOP :

You might also like