📄 16c554.txt
字号:
#define ST_RHR (*(volatile unsigned char *)0x0800)
#define ST_THR (*(volatile unsigned char *)0x0800)
#define ST_IER (*(volatile unsigned char *)0x0900)
#define ST_ISR (*(volatile unsigned char *)0x0A00)
#define ST_FCR (*(volatile unsigned char *)0x0A00)
#define ST_LCR (*(volatile unsigned char *)0x0B00)
#define ST_MCR (*(volatile unsigned char *)0x0C00)
#define ST_LSR (*(volatile unsigned char *)0x0D00)
#define ST_MSR (*(volatile unsigned char *)0x0E00)
#define ST_SPR (*(volatile unsigned char *)0x0F00)
#define ST_DLL (*(volatile unsigned char *)0x0800)
#define ST_DLM (*(volatile unsigned char *)0x0900)
unsigned char tm_recv,tm_send;
// External Interrupt 0 service routine
void int0_isr(void)
{
// Place your code here
if(ST_LSR & 0x01)
tm_recv = ST_RHR;
if(ST_LSR & 0x40)
ST_THR = tm_send;
}
// External Interrupt 1 service routine
void int1_isr(void)
{
// Place your code here
if(ST_LSR & 0x01)
tm_recv=ST_RHR;
if(ST_LSR & 0x40)
ST_THR=tm_send;
}
// External Interrupt 2 service routine
void int2_isr(void)
{
// Place your code here
if(ST_LSR & 0x01)
tm_recv=ST_RHR;
if(ST_LSR & 0x40)
ST_THR=tm_send;
}
void int3_isr(void)
{
// Place your code here
if(ST_LSR & 0x01)
tm_recv=ST_RHR;
if(ST_LSR & 0x40)
ST_THR=tm_send;
}
void reset_554(void)
{
PORTC &= ~0x80; //RST=0
delay(100);
PORTC |= 0x80; //RST=1
delay(80);
PORTC &=~0x80; //RST=0
delay(100);
}
void ST16c554_init(void)
{
reset_554();
ST_LCR=0x80;
ST_DLL=0x0C;
ST_DLM=0x00;
ST_LCR=0x03;
ST_FCR=0x00;
ST_MCR=0x02;
ST_IER=0x03;
ST_SPR=0xAA;
}
汇编:8086
INIMODEM:
MOV DPTR,#0F803H ;DPTR 指向线控寄存器LCR
MOV A,#80H
MOVX @DPTR,A ;置DLAB=1,设置波特率
ANL DPL,#0F8H
MOV A,#0CH
MOVX @DPTR,A ;送波特率常数:9600baud
INC DPL
CLR A
MOVX @DPTR,A
INC DPL
INC DPL ;DPTR 指向线控寄存器LCR
MOV A,#03H
MOVX @DPTR,A ;设置数据帧格式,8位数据,无校验位,1位停止位
INC DPL ;指向MODEM控制寄存器
MOV A,#01H
MOVX @DPTR,A ;置设备终端准备就绪
ANL DPL,#0F8H
ORL DPL,#02H ;指向MODEM控制寄存器MCR
MOV A,#03H ;置FIFO 有效,清接收FIFO
ANL DPL,#0F08H
ORL DPL,#01H ;DPTR 指向中断允许寄存器IER
MOV A,#01H
MOVX @DPTR,A ;设置接收寄存器中有数则中断
RET
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -