在单片机和8279调试的时候发现不能稳定的工作,下面是我写的程序,请高手看看那有问题
D8279 EQU 8000H
C8279 EQU 8001H
ORG 0000H
LJMP START
ORG 000BH
LJMP TIMER0INT
ORG 0013H
LJMP KEYINT
ORG 0040H
START: MOV SP,#90H
SETB P1.5
MOV 73H,#00
LCALL SERIALINIT
LCALL TIMER0INIT
LCALL C8279INIT
SETB TR0
SETB EA
SETB EX1
CLR IT1
;MAIN PROGRAM BEGIN
MAIN:
MOV A,73H
CLR C
SUBB A,#5
JC LOOP
MOV DPTR,#C8279
MOVX A,@DPTR
MOV SBUF,A
LCALL DELAY
SETB P1.5
MOV 73H,#00
LOOP: JNB TI,MAIN
CLR TI
LJMP MAIN
;8279(keyboard) intrrupt sub-program
KEYINT:
PUSH ACC
PUSH PSW
PUSH DPL
PUSH DPH
SETB RS0
CLR RS1
CLR P1.5
MOV DPTR,#D8279
MOVX A,@DPTR
MOV SBUF,A
POP DPH
POP DPL
POP PSW
POP ACC
RETI
TIMER0INT:
PUSH ACC
PUSH PSW
PUSH DPL
PUSH DPH
MOV TH0,#2CH
MOV TL0,#13H
INC 73H
POP DPH
POP DPL
POP PSW
POP ACC
RETI
SERIALINIT: ;INIT SERIAL
MOV SCON,#50H
MOV TL1,#0F9H
MOV TH1,#0F9H
SETB TR1
RET
TIMER0INIT: ;INIT TIMER0
MOV TMOD,#21H
MOV TH0,#2CH
MOV TL0,#13H
SETB ET0
RET
C8279INIT: ;INIT 8279
MOV DPTR,#C8279
MOV A,#01H ;KEY MODE
MOVX @DPTR,A
LCALL DELAY
MOV A,#34H ;CLK=100KHZ,2MHZ/20=100K
MOVX @DPTR,A
LCALL DELAY
MOV A,#0C3H ;CLEAR FIFO RAM
MOVX @DPTR,A
LCALL DELAY
WAIT: MOVX A,@DPTR
JB ACC.7,WAIT
RET
DELAY:
MOV R2,#250
DJNZ R2,$
RET
END |