我串口初始化程序如下:可是就是无法进入中断发送 我已经打开了中断,能进入中断接收数据 void Uart0_Init(void) { uint16 Fdiv; PINSEL0 = (PINSEL0&0xfffffff0)|0x05; //选择串口 U0LCR = 0x83; Fdiv = (Fpclk/16)/UART_BPS; U0DLM = Fdiv/256; U0DLL = Fdiv%256; U0LCR = 0x03;
U0FCR = 0x01; //接收一个字符 U0IER = 0x03; //开接收、发送中断 VICIntSelect = 0x00000000;//设置UART0为IRQ中断,其他中断为IRQ中断 VICVectCntl0=0x26; VICVectAddr0 =(uint32)Uart0_Receive; VICIntEnable = 0x00000040;//UART0使能中断 }
中断程序
void __irq Uart0_Receive(void) { uint8 Re;
if(U0LSR&0x01) //读取数据 { InBuffer[0]=U0RBR; U0IER=0x03; InFlag=1; } else if(U0LSR&0x20)//发送数据 { U0THR=0x54; U0IER=0x01; } VICVectAddr=0; Re=U0IIR; }
|