以下是对AT89S52芯片用汇编语言写的程序,我想加个串口通信能够在电脑端控制,请问要怎么做呢?

2024-12-14 23:46:40
推荐回答(1个)
回答1:

COMDAT EQU 30H
FLAG BIT 00H
ORG 0000H
LJMP MAIN
ORG 0003H
LJMP EX0INT
ORG 0023H
LJMP SERINT
ORG 0030H
EX0INT:
CPL F0
JNB P3.2, $
RETI
SERINT:
PUSH ACC
JNB RI,SERR
CLR RI
MOV A,SBUF
MOV COMDAT,A
SETB FLAG
SERR:
POP ACC
RETI
MAIN:
MOV TMOD, #00H
MOV TH1, #0F0H
MOV TL1, #0CH
MOV IE, #81H ;开外部中断
SETB IT0
SETB TR1
CLR FLAG
LOOP:
JNB FLAG,LOOPC
CLR FLAG
MOV A,COMDAT
.........处理接收到的命令。
LOOPC:
JBC TF1, LOOP1
JB F0, $
AJMP LOOP
LOOP1:
MOV TH1, #0F0H
MOV TL1, #0CH
CLR TF1
CPL P1.7
AJMP LOOP

END