main函数中调用Isr_Init,但只能产生一次中断,再发字符就不会再有Urxd1 exception!!!打印出来。谢谢!
void Isr_Init(void){
rINTCON=0x5;
rINTMOD=0x0;
pISR_URXD1=(unsigned)HaltUrxd1;
rINTMSK=~(BIT_GLOBAL | BIT_URXD1 );
}
void HaltUrxd1(void)
{ rI_ISPC = BIT_URXD1;
Uart_Printf("Urxd1 exception!!!\n");
}
另外,串口其他寄存器的值如下:
void Uart_Init(int mclk,int baud)
{
int i;
if(mclk==0)
mclk=MCLK;
rUFCON0=0xf7;
rUFCON1=0xf7;
rUMCON0=0x0;
rUMCON1=0x0;
rULCON0=0x3;
rUCON0=0x245;
rUBRDIV0=( (int)(mclk/16./baud + 0.5) -1 );
rULCON1=0x3;
rUCON1=0x245;
// rUCON1=0x345;
rUBRDIV1=( (int)(mclk/16./baud + 0.5) -1 );
}
开始怀疑是RX FIFO 没被清空,然后在中断服务程序中加rUFCON1=0xF7; 有时可以产生多次中断,有时不行。是因为FIFO没被有效清空,还是其他什么原因?
关键词:
串口
接收
字符
中断
问题