单片机U1发送数据参考程序如下:
ORG 0
LJMP MAIN
ORG 23H
CLR TI
MOV A,P1
MOV SBUF,A
RETI
ORG 30H
MAIN: MOV SCON,#40H;串行口方式1,禁止接收
MOV TMOD,#20H
MOV TL1,#0E0H
MOV TH1,#0E0H
SETB TR1
MOV IE, #90H
MOV A,P1
MOV SBUF,A
SJMP $
END
单片机U2接收参考程序如下:
ORG 0
LJMP MAIN
ORG 23H
CLR RI
MOV A,SBUF
MOV P2,A
RETI
ORG 30H
MAIN: MOV SCON,#50H;串行口方式1,允许接收
MOV TMOD,#20H
MOV TL1,#0E0H
MOV TH1,#0E0H
SETB TR1
MOV IE, #90H
SJMP $
END
|