You are on page 1of 6

電路圖

Rth

1
f   606kHz
1.1RC
The conversion time = 100 us
Vref
2
Computer Control Lab 2
程式碼

ORG 0000H
MOV P2, #0FFH ;Make port2 input.
SETB P1.6 ;Make p1.6 input.
SETB P1.0 ;Turn off LED RED.
SETB P1.1 ; Turn off LED YELLOW.
SETB P1.2 ; Turn off LED GREEN.
MOV DPTR,#0100H
LOOP1:
CLR P1.5 ;WR=0.
SETB P1.5 ;WR=1;Create L to H.

Computer Control Lab 3


WAIT:
JB P1.6, WAIT ;Wait for end of conversion.
CLR P1.7 ;Read converted data in.
MOV A, P2
ACALL DISPLAY
MOVX @DPTR, A
INC DPTR
MOV A,DPH
SUBB A,#0
JNZ LOOP2
MOV DPTR,#0100H

Computer Control Lab 4


LOOP2:
SETB P1.7 ;For next converted data in.
AJMP LOOP1
DISPLAY:
MOV B,A ;Save in B.
CLR C
SUBB A,#102 ;Smaller than 2V.
JNC BIG
CLR P1.2 ;Turn on Green LED.
MOV A, B ; Restore the data
RET

Computer Control Lab 5


BIG:
MOV A, B
SUBB A, #153 ;Larger then 3V.
JNC LARGE ;YES
CLR P1.1 ;Turn on the YELLOW LED
MOV A, B
RET
LARGE:
CLR P1.0 ; Turn on the RED LED
MOV A, B
RET

Computer Control Lab 6


Computer Control Lab 7

You might also like