LED_0 EQU 30H
LED_1 EQU 31H
LED_2 EQU 32H
ADC EQU 35H
ST BIT P2.0
OE BIT P2.1
EOC BIT P3.2
ORG 0000H
LJMP START
ORG 0100H
START:
MOV LED_0,#00H
MOV LED_1,#00H
MOV LED_2,#00H
MOV ADC,#00H
MOV DPTR,#0FE00H
MOV P2,0
WAIT:
SETB ST
MOV A,#1
MOVX @DPTR,A
MOV R6,#0FFH ;等待转换
DJNZ R6,$
CLR ST
SETB OE
MOVX A,@DPTR ;读转换
NOP
MOV ADC,A
CLR OE
MOV A,ADC
MOV B,#100
DIV AB
MOV LED_2,A
MOV A,B
MOV B,#10
DIV AB
MOV LED_1,A
MOV LED_0,B
LCALL DIS
SJMP START
DIS:
INC A
MOV A,LED_2
MOVC A,@A+PC
MOV P1,A
SETB P3.4 ;开LED1
CLR P3.5 ;关LED2
CLR P3.6 ;关LED3
LCALL DEL
INC A
MOV A,LED_1
MOVC A,@A+PC
MOV P1,A
CLR P3.4 ;关LED1
SETB P3.5 ;开LED2
CLR P3.6 ;关LED3
LCALL DEL
INC A
MOV A,LED_0
MOVC A,@A+PC
MOV P1,A
CLR P3.4 ;关LED1
CLR P3.5 ;关LED2
SETB P3.6 ;开LED3
LCALL DEL
RET
TAB: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H
DB 80H,90h,88H,83H,0C6H,0A1H,86h,8EH
DEL: MOV R7,#10
D1: MOV R6,#249
DJNZ R6,$
DJNZ R7,D1
RET
END
这芯片型号是?内置ADC?
你仿真时在RAM能看到AD值?
还是用C写吧