Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

18ECL47 MICROCONTROLLER LABORATORY

1. (a) Aim: Write an ALP to interface a simple toggle switch to 8051 and write
an ALP to generate an interrupt which switches on an LED continuously as
long as the switch is on.

;------------------Start of Program------------------------
ORG 0H
AJMP MAIN
;------------------Start of ISR FOR INT1-------------------
ORG 0013H
CLR P0.3 ;Switch off the LED
HERE: JNB P3.6, HERE ;Wait for a high signal at switch connected at P3.6
SETB P0.3 ; Switch on the LED
RETI
;------------------Start of Main-----------------------------
ORG 30H
MAIN: MOV P0, #00H
MOV IE, #10000100B ;Configuration of interrupt
WAIT: SJMP WAIT
END

Link for code explanation:


https://drive.google.com/drive/folders/1edAiu4_kBYKbpFc2vzb_kFmvUSpav-Le
Link for demo:
https://drive.google.com/drive/folders/1edAiu4_kBYKbpFc2vzb_kFmvUSpav-Le

(b) Aim: Interface a simple toggle switch to 8051 and write an ALP to generate an
interrupt which switches on an LED only once for a small time when the switch is
turned on.

; -------------------Start of Program------------------------

ORG 0H
AJMP MAIN

;------------------Start of ISR FOR INT1-------------------


ORG 0013H
CLR P0.3 ; switch off the LED
HERE: JNB P3.6,HERE ; Wait for a high signal at switch connected at P3.6

Department of ECE, CMRIT, Bangalore 2019-20 1


18ECL47 MICROCONTROLLER LABORATORY

SETB P0.3 ; switch on the LED


ACALL DELAY
CLR P0.3 ; switch off the LED after a small delay
RETI
;------------------Start of Main-----------------------------
ORG 30H
MAIN: MOV P0, #00H
MOV IE,#10000100B
SETB TCON.2 ; Configuration for edge triggered interrupt
WAIT: SJMP WAIT
;------------------Start of Delay Subroutine-----------------------------
DELAY:MOV R3,#0FH
L3: MOV R2, #0FFH
L2: MOV R1, #0FFH
L1: DJNZ R1,L1
DJNZ R2,L2
DJNZ R3,L3
RET
END

Link for code explanation:


https://drive.google.com/drive/folders/1edAiu4_kBYKbpFc2vzb_kFmvUSpav-Le
Link for demo:
https://drive.google.com/drive/folders/1edAiu4_kBYKbpFc2vzb_kFmvUSpav-Le

Department of ECE, CMRIT, Bangalore 2019-20 2

You might also like