自已写了一个UART3的驱动,用UART3_Trs()发送数据时在串口端显示数据正常,但是得等到有两个字节才会有信号输出。
例如:
while(1)
{
UART_Trs(10);
Delay(100);
}
串口端口用示波器测得的数据显示是两个数据10是一起发送的,两个中间并无时延,但两个两个中间延时为Delay(200),不知道有哪位仁兄碰到过这个问题,帮忙看看驱动写得有什么问题
void UART3_Trs(unsigned char a)
{
while(!(U3LSR&0x40)) ; //wait for the Tx empty
U3THR = a;
}
void UART3_Init(void)
{
UARTCLK_CTRL = 0xF; //standard UARTn HCLK Enabled
UART_CTRL = 0; //UART3 does not use modem control pins
UART_CLKMODE = 0xaa0; //UART3,4,5,6 autoclock mode,
//the high bits of this register can be read to check the clock state of UARTn
UART_LOOP = 0x00; //Turn off all loopback
U3FCR = 0x0F; //FIFO enable, if disable, what will happen.
//get interrupt ID from U3IIR
U3MCR = 0x00; //disable modem loopback mode
U3LCR = 0x83; //enable accees to U3DLL,u3DLM, disable access to U3IER,U3THR,U3RBR
//1 stop bit, 8bit character length, no parity check
U3DLL = 162;
U3DLM = 0;
U3LCR = 0x03; //disable accees to U3DLL,u3DLM, enable access to U3IER,U3THR,U3RBR
//1 stop bit, 8bit character length, no parity check
//get the Rx,Tx information from U3LSR
//get the modem state from U3_MCR
//get the receiver FIFO state from U3RXLEV
U3IER = 0x00; //disable all interrupt
U3CLK = 0x11040; //HCLK as the input, X:0x10, Y:0x40;
} |