Download Microcontroller & Interfacing - Biomedical Department

Transcript
EXPERIMENT NO. 16
AIM: Interface ADC0808 with AT89C51 microcontroller. Write a program to read analog
voltage applied at the input of ADC. Display hex code of analog value on LEDs connected
at port P0.
Circuit diagram:
Program:
; Microcontroller connections to ADC0808/9 lines.
START
EQU P3.6
; Pin 6 Start
EOC
EQU P3.2
; Pin 7 EOC
OE
EQU P3.7
; Pin 9 Output Enable
ALE
EQU P3.6
; Pin 22 ALE
LOOP:
ORG 00h
MOV P0,#00h
MOV P1,#0FFH
MOV P2,#00H
MOV R0,#05H
MOV P0,#0FFH
ACALL DELAY
MOV P0,#00H
ACALL DELAY
DJNZ R0,LOOP
; P0 OUTPUT PORT TO DRIVE LEDs
; P1 INPUT PORT TO READ ADC
; P2 OUTPUT PORT TO SELECT CHANNEL
BACK:
MOV P2,#00H
ACALL SDELAY
; SELECT ADC CHANNEL 0
Lab Manual of Microcontroller & Interfacing
Page 72