ADC_CONTR DATA 0BCH
ADC_RES DATA 0BDH
ADC_RESL DATA 0BEH
ADCCFG DATA 0DEH
P_SW2 DATA 0BAH
ADCTIM XDATA 0FEA8H
ADCEXCFG XDATA 0FEAdH
P1M1 DATA 091H
P1M0 DATA 092H
P0M1 DATA 093H
P0M0 DATA 094H
P2M1 DATA 095H
P2M0 DATA 096H
P3M1 DATA 0B1H
P3M0 DATA 0B2H
P4M1 DATA 0B3H
P4M0 DATA 0B4H
P5M1 DATA 0C9H
P5M0 DATA 0CAH
ORG 0000H
LJMP MAIN
ORG 0100H
MAIN:
MOV SP, #5FH
MOV P0M0, #00H
MOV P0M1, #00H
MOV P1M0, #00H
MOV P1M1, #00H
MOV P2M0, #00H
MOV P2M1, #00H
MOV P3M0, #00H
MOV P3M1, #00H
MOV P4M0, #00H
MOV P4M1, #00H
MOV P5M0, #00H
MOV P5M1, #00H
MOV P1M0,#00H ; Set P1.0 as ADC input
MOV P1M1,#01H
MOV P_SW2,#80H
MOV DPTR,#ADCTIM ; Set ADC internal timing
MOV A,#3FH
MOVX @DPTR,A
MOV DPTR,#ADCEXCFG
; MOV A,#04H ; Set the ADC to convert 2 times to take the average automatically
MOV A,#05H ; Set the ADC to convert 4 times to take the average automatically
; MOV A,#06H ; Set the ADC to convert 8 times to take the average automatically
; MOV A,#07H ; Set the ADC to convert 2 times to take the average automatically
MOVX @DPTR,A
MOV P_SW2,#00H
MOV ADCCFG,#0FH ; Set the ADC clock to the system clock/2/16
MOV ADC_CONTR,#80H ; Enable ADC module
LOOP: