![](http://datasheet.mmic.net.cn/260000/P80C550EBAA_datasheet_15927746/P80C550EBAA_9.png)
Philips Semiconductors
Product specification
80C550/83C550/87C550
80C51 8-bit microcontroller family
4K/128 OTP/ROM/ROMless, 8 channel 8 bit A/D, watchdog timer
1998 May 01
9
Sample A/D Routines
The following routines demonstrate two methods of operating the
A/D converter. The first method uses polling to determine when the
A/D conversion is complete. The second method uses the A/D
interrupt to flag the end of conversion.
The routine ReadAD will start a read of the A/D channel identified by
R7, and wait for the conversion to complete, polling the A/D interrupt
flag. The result is returned in the accumulator.
ReadAD:MOV A,#08h
ORL
MOV ADCON,A;
ADLoop: MOV A,ADCON
JNB
MOV A,ADAT
MOV ADCON,#0
RET
;Basic A/D start command.
;Add channel # to be read.
;Start A/D.
;Get A/D status.
A,R7
ACC.4,ADLoop;Wait for ADCI (A/D ;finished).
;Get conversion result
;Clear ADCI.
The routine StartAD will start a read of the A/D channel identified by
R7 and exit back to the calling program. When the conversion is
complete, the A/D interrupt occurs, calling the A/D interrupt service
routine. The result of the conversion is returned in register R6.
StartAD: MOV A,#08h
ORL
MOV ADCON,A
RET
.
.
.
ORG 2Bh
ADInt:
MOV R6,ADAT
MOV ADCON,#0
RETI
;Basic A/D start command.
;Add channel # to be read.
;Start A/D.
A,R7
;A/D interrupt address.
;Get conversion result.
;Clear ADCI.
R
S
V
ANALOG
INPUT
C
S
C
C
To Comparator
+
I
N
I
N+1
Sm
N+1
Sm
N
Rm
N+1
Rm
N
Multiplexer
Rm = 0.5 - 3 k
CS + CC = 15pF maximum
RS = Recommended < 9.6 k
for 1 LSB @ 12MHz
NOTE:
Because the analog to digital converter has a sampled-data comparator, the input looks capacitive to a source. When a conversion
is initiated, switch Sm closes for 8tcy (8
μ
s @ 12MHz crystal frequency) during which time capacitance Cs + Cc is charged. It should
be noted that the sampling causes the analog input to present a varying load to an analog source.
SU00199
Figure 3. A/D Input: Equivalent Circuit