I have the following problem that is very odd.
I have a very simple program that waits one char from the uart0 and
sends it back to it.
If I set the baudrate to 57600, it works ok, but if I set the baud rate
to 115200, the host (PC) understands any data I send, but the LPC just
gives Frame errors even if a single byte is sent.....
I'm using a LPC2146 @ 12Mhz
Using these constants in the baud rate generator should give an error of
0,16%, and the transmission works... Why can't I receive data ?
Thanks, Mauricio
This is the code:
void ser0_init(void)
{
U0IER = 0;
U0IIR;
U0RBR;
U0LSR;
U0LCR = 0x83; // Enable access to divisor latchs
// 57600 @ PERCLK = 12Mhz
// U0DLL = 13;
// U0DLM = 0;
// U0FDR = 1<<4|0; // MulVal[7..4] DivAddVal[3..0]
// 115200 @ PERCLK = 12Mhz
U0DLL = 1;
U0DLM = 0;
U0FDR = 2<<4|11; // MulVal[7..4] DivAddVal[3..0]
U0LCR = 0x03; // 8n1
U0FCR = 0x87; // FIFO enabled and cleared; Trigger @ 8 bytes
}
unsigned char ser0_getc (void)
{
while (!(U0LSR&0x01)); // RDR
return U0RBR;
}
void ser0_putc(unsigned char ch)
{
while (!(U0LSR&0x20)); // THRE
U0THR = ch;
}
int main(void)
{
Initialize();
ser0_init();
ser0_putc('O');
ser0_putc('k');
ser0_putc(0x0d);
ser0_putc(0x0a);
while (1)
{
ser0_putc(ser0_getc());
}
}Message
weird problem in UART
2006-01-17 by Mauricio Scaff
Attachments
- No local attachments were found for this message.