MOD EQU 7000H CMR EQU 7001H SR EQU 7002H IR EQU 7003H IER EQU 7004H BTR0 EQU 7006H BTR1 EQU 7007H OCR EQU 7008H REGTEST EQU 7009H ALC EQU 700BH ECC EQU 700CH EWLR EQU 700DH RXERR EQU 700EH TXERR EQU 700FH TXB EQU 7010H RXB EQU 7010H ACR EQU 7010H AMR0 EQU 7014H AMR1 EQU 7015H AMR2 EQU 7016H AMR3 EQU 7017H RMC EQU 701DH RBSA EQU 701EH CDR EQU 701FH ORG 0000H LJMP MAIN ORG 0003H LJMP INT0 ORG 0050H MAIN: MOV R0,#07fH CLR A MOV @R0,A DJNZ R0,$-1 MOV SP,#60H SETB P1.2 LL0: MOV DPTR,#MOD ;进入复位模式 MOV A,#01H MOVX @DPTR,A NOP MOVX A,@DPTR JNB ACC.0,LL0 MOV DPTR,#CDR MOV A,#0C8H MOVX @DPTR,A NOP MOV DPTR,#OCR MOV A,#1AH MOVX @DPTR,A NOP MOV DPTR,#BTR0 MOV DPTR,#BTR1 MOV A,#0FFH MOVX @DPTR,A NOP MOV DPTR,#AMR1 MOV A,#0FFH MOVX @DPTR,A NOP MOV DPTR,#AMR2 MOV A,#0FFH MOVX @DPTR,A NOP MOV DPTR,#AMR3 MOV A,#0FFH MOVX @DPTR,A NOP AS2: MOV DPTR,#MOD ;回到操作模式 MOV A,#04H MOVX @DPTR,A MOVX A,@DPTR CJNE A,#4,AS2 NOP MOV DPTR,#IER ;只开放接收中断 MOV A,#1 MOVX @DPTR,A SETB EX0 SETB EA NOP NOP AS3: NOP MOV P2,#7FH MOV R0,#TXB ;发送缓冲器地址 MOV R7,#11 MOV DPTR,#TXBUF ;待发送内容(待修改,应为IDATE) CLR A A5: MOV A,B MOVC A,@A+DPTR MOVX @R0,A INC R0 INC B DJNZ R7,A5
MOV R0,#CMR MOV A,#10H ;自收发命令 MOVX @R0,A NOP JNB 1,$ ;等待接收中断 CLR 1 ;ACALL DLY MOV R7,#11 MOV DPTR,#RXB ;接收内容送到IDATA-50H显示 MOV R1,#50H A4: NOP MOVX A,@DPTR MOV @R1,A INC DPTR INC R1 DJNZ R7,A4 CLR P1.2 NOP AJMP $ INT0: NOP ;接收中断 SETB 1 RETI
DLY:CLR A MOV R5,A MOV R6,A L5:NOP NOP DJNZ R5,L5 DJNZ R6,L5 RET TXBUF: DB 08H,83H,0E0H,31H,32H,13H,14H,15H,16H,17H,18H ;待发送数据 END |