本帖最后由 ewewre 于 2011-6-18 11:38 编辑
我用串口调试助手发送,为什么就第一次有用,再发就没用了,数码管闪一下就跳成原来的值了!还有就是要发送一组数据程序要怎么改啊,谢谢了!
ORG 0000H
LJMP START
ORG 0013H
LJMP COUNTER
ORG 0023H
LJMP RS232
ORG 0030H
START: MOV SP,#70H
RESET: MOV R1,#00H
RESET_1:MOV R2,#00H
DJNZ R2,$
DJNZ R1,RESET_1
MOV PCON,#00H
MOV TMOD,#21H
MOV SCON,#50H
MOV TH1,#0FDH
MOV TL1,#0FDH
MOV TH0,#00H
MOV TL0,#00H
MOV TCON,#45H
MOV IE,#95H
MOV DPTR,#000AH
MOV A,#20H
MOVX @DPTR,A
MOV DPTR,#000BH
MOV A,#02H
MOVX @DPTR,A
MAIN: MOV SP,#70H
DISPL: MOV DPTR,#000AH
MOVX A,@DPTR
JB ACC.7,DISPL
MOV R1,#30H
MOV R2,#0CH
MOV DPTR,#000EH
DISPL_1:MOVX A,@DPTR
MOV @R1,A
INC DPL
INC R1
DJNZ R2,DISPL_1
DISPL_3:MOV R1,#3BH
MOV R2,#0CH
DISPL_4:MOV A,@R1
LCALL BDISP
DEC R1
DJNZ R2,DISPL_4
SETB P1.2
NOP
NOP
CLR P1.2
LCALL DELAY
LJMP MAIN
BDISP: PUSH DPL
PUSH DPH
MOV DPTR,#LED
MOVC A,@A+DPTR
MOV R4,#08H
BDISP_1:JB ACC.1,BDISP_2
SETB P1.0
SJMP BDISP_3
BDISP_2:CLR P1.0
BDISP_3:CLR P1.1
NOP
NOP
SETB P1.1
RR A
DJNZ R4,BDISP_1
CLR P1.2
POP DPH
POP DPL
RET
DELAY: MOV R5,#02H
DELAY_1:MOV R6,#00H
DELAY_2:MOV R7,#00H
DJNZ R7,$
DJNZ R6,DELAY_2
DJNZ R5,DELAY_1
RET
COUNTER:
CLR EX1
CLR EA
MOV R5,#02H
COUNTER_1:
MOV R6,#00H
COUNTER_2:
MOV R7,#00H
DJNZ R7,$
DJNZ R6,COUNTER_2
DJNZ R5,COUNTER_1
JB P3.3,OUTCOUNTER
MOV R1,#30H
MOV DPTR,#000EH
COUNTER_4:
MOVX A,@DPTR
MOV @R1,A
MOV R0,#30H
LCALL NUMADD
COUNTER_5:
MOV R1,#30H
MOV DPTR,#000EH
COUNTER_6:
MOV A,@R1
MOVX @DPTR,A
OUTCOUNTER:
POP DPH
POP DPL
MOV DPTR,#MAIN
PUSH DPL
PUSH DPH
CLR IE1
SETB EX1
SETB EA
RETI
RS232: JNB TI,RS232_1
LCALL ENDT
RS232:
CLR RI
CLR ES
CLR EX1
CLR EA
MOV R5,#02H
RS232_2:
MOV R6,#00H
RS232_3:
MOV R7,#00H
DJNZ R7,$
DJNZ R6,RS232_3
DJNZ R5,RS232_2
PUSH ACC
PUSH PSW
CLR RI
MOV A,SBUF
MOV 6AH,A
MOV R1,#30H
MOV @R1,A
RDISPL_1:MOV SP,#70H
/* MOV R1,#30H
MOV R2,#0CH
RDISPL_2:
MOV @R1,A
INC DPL
INC R1
DJNZ R2,RDISPL_2 */
MOV @R1,6AH
MOV R1,#3BH
RDISPL_3:MOV R2,#0CH
RDISPL_4:MOV A,@R1
LCALL BDISP
DEC R1
DJNZ R2,RDISPL_4
SETB P1.2
NOP
NOP
NOP
NOP
CLR P1.2
LCALL DELAY
/*RDISPL_4:MOV SP,#70H
MOV @R0,6AH
MOV A,@R1
LCALL BDISP
SETB P1.2
NOP
NOP
CLR P1.2
LCALL DELAY */
/* POP DPH
POP DPL
MOV DPTR,#LED
PUSH DPL
PUSH DPH */
POP PSW
POP ACC
CLR IE1
SETB EX1
CLR RI
SETB ES
SETB EA
ENDT: RETI
NUMADD: MOV B,#01H
NUMADD_1:
MOV A,@R0
ADD A,B
DA A
MOV B,A
ANL A,#0FH
MOV @R0,A
MOV A,B
ANL A,#0F0H
SWAP A
MOV B,A
DEC R0
DJNZ R1,NUMADD_1
RET
LED: DB 0FCH,60H,0DAH,0F2H,66H,0B6H,0BEH,0E4H,0FEH,0F6H,00H,02H,00H,00H,00H,00H
DB 0FDH,61H,0DBH,0F3H,67H,0B7H,0BFH,0E5H,0FFH,0F7H,00H,00H,00H,00H,00H,00H
END |