代码如下:
AD_VALUE_HIGH4 EQU 30H
AD_VALUE_LOW8 EQU 31H
LED_STATUS EQU 32H
ICL7109_LBEN EQU P2.4
ICL7109_HBEN EQU P2.5
ICL7109_CE EQU P2.6
ICL7109_RUN EQU P2.7
LED EQU P2.3
LED2_SELECT EQU P3.7
LED1_SELECT EQU P3.6
LED0_SELECT EQU P3.5
ORG 0000H
SJMP MAIN
ORG 000BH
AJMP TIMER0_SERVICE
ORG 001BH
AJMP INT1_SERVICE
ORG 0023H
DS 3
ORG 0030H
MAIN:
MOV SP, #40H
ACALL INIT_ICL7109
ACALL INIT_TIMER0
SETB EA
LOOP:
NOP
NOP
SJMP LOOP
INIT_ICL7109:
CLR ICL7109_CE
SETB ICL7109_RUN
SETB IT1
SETB EX1
RET
INIT_TIMER0:
MOV TMOD, #01H
MOV TH0, #0F8H
MOV TL0, #0CCH
SETB ET0
SETB TR0
MOV LED_STATUS, #00H
RET
INT1_SERVICE:
CLR ICL7109_HBEN
SETB ICL7109_LBEN
NOP
MOV AD_VALUE_HIGH4, ICL7109_HBEN;代码错误指向这里
SETB ICL7109_HBEN
CLR ICL7109_LBEN
NOP
MOV AD_VALUE_LOW8, ICL7109_LBEN;错误指向这里
CPL LED
RETI
TIMER0_SERVICE:
MOV TL0, #0CCH
MOV TH0, #0F8H
PUSH ACC
MOV A, LED_STATUS
CJNE A, #00H,NEXT1
SETB LED2_SELECT
CLR LED0_SELECT
MOV A, AD_VALUE_LOW8
ANL A, #0FH
MOV DPTR, #TAB
MOVC A, @A+DPTR
MOV P1, A
MOV LED_STATUS, #01H
SJMP EXIT
NEXT1:
CJNE A, #01H, NEXT2
SETB LED0_SELECT
CLR LED1_SELECT
MOV A, AD_VALUE_LOW8
SWAP A
ANL A, #0FH
MOV DPTR, #TAB
MOVC A, @A+DPTR
MOV P1, A
MOV LED_STATUS, #02H
SJMP EXIT
NEXT2:
SETB LED1_SELECT
CLR LED2_SELECT
MOV A, AD_VALUE_HIGH4
ANL A, #0FH
MOV DPTR, #TAB
MOVC A, @A+DPTR
MOV P1, A
MOV LED_STATUS, #00H
EXIT:
POP ACC
RETI
TAB:
DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H
DB 80H,90H,88H,83H,0A7H,0A1H,86H,8EH
END
|