|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
请教各位高手,我编的这段串口通信程序,为什么无法进入中断?就是下面的接收中断函数void SciRecv_INT(void)interrupt 4 using 0
#include <AT89X51.H>
unsigned char Timer0Count;
unsigned char rdata,sdata[8];
unsigned int i=0;
sbit SendData = P3^4;
sbit RecvData = P3^5;
sbit watchdog = P3^2;
bit try=0;
void Sci_SendData(void);
void main(void)
{
//interrupt manage start//
IE = 0x00; //中断屏蔽寄存器(可位寻址). 禁止所有中断
IP = 0x00; //中断优先级寄存器(可位寻址). 无优先级
TCON = 0x00; //定时器/计数器控制寄存器
PCON = 0x80; //串行通信方式1,2,3的波特率加倍.
SCON = 0x50; //选择串行方式1,及8位UART方式,波特率可变
TMOD = 0x21;
TH1 = 0xFF; //波特率为62.5K
TL1 = 0xFF;
Timer0Count = 7;
TH0 = 0x3C;
TL0 = 0xB0;
SendData = 1; //禁止串行通讯485发送数据 (0时发送)
RecvData = 0; //允许接收
//interrupt manage end//
PX1 = 1; //置位INT1中断优先级
EA = 1; //全局禁止位.
EX1 = 1; //开INT1中断
ES = 1; //开串口中断
ET0 = 1; //开T0中断
TR0 = 1; //定时器0运行
TR1 = 1; //定时器1运行
while(1)
{
watchdog = ~watchdog;
}
}
void SciRecv_INT(void)interrupt 4 using 0
{
EA = 0;
ES = 0;
if(RI)
{
rdata = SBUF;
RI = 0;
}
else
EA = 1;
ES = 1;
}
void Timer0_INT(void)interrupt 1 using 3
{
SendData = 0;
RecvData = 1;
if(Timer0Count==0)
{
SBUF=0xa0;
while(TI==0);
TI= 0;
Timer0Count = 7;
if(try==0)
{
P2_0 = 0;
try = 1;
}
else
{
P2_0 = 1;
try = 0;
}
}
else
Timer0Count--;
SendData = 1;
RecvData = 0;
}
|
|