Lab9 Report
Lab9 Report
Lab9 Report
LAB # 9
To interface an Analogue to Digital Converter (ADC) with 8051 MCU using
Assembly Language programming
Batch FA17-BCE-A
Code:
ADC_WR EQU P2.0
ADC_RD EQU P2.1
ADC_INT EQU P2.2
LED EQU P1
ADC EQU P3
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
CALL DELAY
CALL CONVERT ;RESULT IS IN A
MOV LED, A ;WRITE RESULT TO BAR DISPLAY
JMP MAIN
CONVERT:
SETB ADC_WR
SETB ADC_RD
NOP
CLR ADC_WR
NOP
SETB ADC_WR
JB ADC_INT,$ ;POLL FOR INTR = 0
CLR ADC_RD
NOP
MOV A, ADC ;READ ADC PORT IN A
SETB ADC_RD
RET
;SUBROUTINE GENERATES SOME DELAY
DELAY:
MOV R1, 250
LOOP1:
MOV R0, #0FFH
DJNZ R0, $
MOV R0, #0FFH
DJNZ R0, $
MOV R0, #0FFH
DJNZ R0, $
MOV R0, #0FFH
DJNZ R0, $
DJNZ R1, LOOP1
RET
END
Proteus Simulation:
TASK 2:
Code:
ADC_WR EQU P2.0
ADC_RD EQU P2.1
ADC_INT EQU P2.2
LED EQU P1
ADC EQU P3
ORG 0000H
LJMP MAIN
ORG 0030H
MAIN:
CALL DELAY
CALL CONVERT ;RESULT IS IN A
CJNE A,#150,LEDOFF
JMP LEDON
JMP MAIN
CONVERT:
SETB ADC_WR
SETB ADC_RD
NOP
CLR ADC_WR
NOP
SETB ADC_WR
JB ADC_INT,$ ;POLL FOR INTR = 0
CLR ADC_RD
NOP
MOV A, ADC ;READ ADC PORT IN A
SETB ADC_RD
RET
LEDOFF:
MOV LED, #0FFH ;WRITE RESULT TO BAR DISPLAY
LEDON:
MOV LED, #00H ;WRITE RESULT TO BAR DISPLAY
DELAY:
MOV R1, 250
LOOP1:
MOV R0, #0FFH
DJNZ R0, $
MOV R0, #0FFH
DJNZ R0, $
MOV R0, #0FFH
DJNZ R0, $
MOV R0, #0FFH
DJNZ R0, $
DJNZ R1, LOOP1
RET
END
Conclusion:
This lab experiment proved to be crucially helpful in understanding basic concepts of different
scenarios related to this specific microcontroller and so with the help of proteus and different simulation
softwares, this purpose was achieved.