ADC0832转换程序
CLK bit P1.6
DATA_I bit P1.4
DATA_O bit P1.5
CS bit P1.2
org 0000h
ajmp start
org 0020h
adc0832: ;;A/D处理主程序
CLR A
MOV R7,A
CLR CS
SJMP adc_wait ;;判断A/D是否准备好?
wait_loop: JNB DATA_O,adc_process
adc_wait: SETB CLK
NOP
NOP
CLR CLK
NOP
NOP
SJMP wait_loop
adc_process: CLR A ;;A/D处理子程序
MOV R6,A
pro_loop: SETB CLK
NOP
NOP
CLR CLK
NOP
NOP
MOV A,R7
ADD A,ACC
MOV R7,A
MOV C,DATA_O
CLR A
RLC A
ORL A,R7
MOV R7,A
INC R6
CJNE R6,#08H,pro_loop
SETB CS
RET
;==========================================================================
;主程序
start:
LCALL adc0832
MOV P0,R7
SJMP start
END