打印

LPC3250串口问题

[复制链接]
2185|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
wacer|  楼主 | 2009-12-9 14:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
自已写了一个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;
}

相关帖子

沙发
wacer|  楼主 | 2009-12-9 14:55 | 只看该作者
自己怀疑是不是有什么设置要求了队列中有两个字节才往外发数据?

使用特权

评论回复
板凳
虎虎生威| | 2009-12-9 20:29 | 只看该作者
没遇到过……

使用特权

评论回复
地板
hahahaluo| | 2010-10-20 21:55 | 只看该作者
虽然没遇到过,感觉是不是这样改改就行
void UART3_Trs(unsigned char a)
{
   U3THR = a;
   while(!(U3LSR&0x40))  ;  //wait for the Tx empty
}

使用特权

评论回复
5
3B1105| | 2010-10-24 14:25 | 只看该作者
缓冲区大小你定义的多少了?

使用特权

评论回复
6
wang1114| | 2010-11-4 22:51 | 只看该作者
因为每个串口本身就有一个缓冲区,64字节的,你说的可能和这个有关

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

2

帖子

0

粉丝