发表于:2006-07-29 00:16:00
4楼
串口中断程序:
UART: PUSH ACC
PUSH PSW
SETB RS0
SETB RS1
JBC RI, UART1
LJMP RETURN
UART1: MOV A, SBUF
MOV R1, 2EH //定义buffer地址
MOV @R1, A
INC 2EH
MOV A, 2EH
CJNE A, #40H, RETURN //收到10个字节;
MOV 2EH, #35H //再赋初值,
RETURN:CLR TI
POP PSW
POP ACC
RETI
串口发送程序:
SEND: CLR ES
MOV A, #0A5H
MOV SBUF, A
SEND0: JBC TI,SEND1
JMP SEND0
...自已定义发送多少个字节
...
SEND13:JBC TI,SEND14
JMP SEND13
SEND14:SETB ES
RET
初始化串口:
SETUP: MOV TMOD, #25H
//T1 for rs232 baud generator, 8 bit auto-reload
MOV TL1, #0FDH ; rs232 baud rate 9600
MOV TH1, #0FDH
....
....