STC使用独立波特率BTR,开串行中断定时器1就不能进入中断。
如题:void UartInit()
{
AUXR = 0x11;
SCON = 0x50;
PCON = 0x90;
EA = 1;
// ES = 1;//加了此句就T0不能运行了
BRT = 0xFA;
}
void TimerInit(void)
{
TMOD = 0x10; //set timer1 as mode1 (16-bit)
TL1 = TIME_1MS; //initial timer1 low byte
TH1 = TIME_1MS >> 8; //initial timer1 high byte
TR1 = 1; //timer1 start running
ET1 = 1; //enable timer1 interrupt
EA = 1; //open global interrupt switch
}
void tm1_isr() interrupt 3 using 1
{
TL1 = TIME_1MS; //reload timer1 low byte
TH1 = TIME_1MS >> 8; //reload timer1 high byte
if(sys_tick1<2000)
{
sys_tick1++;
}
SCL ^= 1;
}
问题解决了:
加了
void UARTINT() interrupt 4
{
u8 c;
if(RI==0)
return;
ES = 0;
RI = 0;
c= SBUF;
if(0 == FIFOBufferWrite(&uart_buffer, c));
ES = 1;
}就好了
页:
[1]