--- In l..., "mahaboob" wrote:
>
> Hi Guys,
>
> I am very new to LPC2148, I try to implement the UART1 for the serial
communication. I am using the following code, which provide error characters in
the Hyberterminal not the desired one. I need your Help.
>
> regards,
>
> Mahaboob.
What crystal frequency?
What CCLK?
What PCLK?
What Baudrate?
You didn't set the Fractional Baudrate Divider so you would need a specific
crystal of 14.7456 MHz. More likely, you have a 12 MHz crystal (to support USB)
so, for most baudrates, there is no integer divisor that is sufficiently
accurate. That's why NXP included the fractional divider hardware.
Assuming a crystal of 12 MHz, a CCLK of 60 MHz and a PCLK of 15 MHz, this code
sets UART1 for 38400,n,8,1
void UART1_init(void)
{
PINSEL0 |= 0x05 << 16; // enable UART1 pins
U1LCR = 0x83; // 8,n,1 and turn on DLAB
U1DLM = 0x00;
U1DLL = 0x0D; // divide PCLK by 13
U1FDR = (8 << 4) + 7; // multiply by 8, divide by 8 + 7
U1LCR &= ~(0x80); // turn off DLAB
U1FCR = 0x07; // reset and enable FIFO, RX Trigger level 0 - 1 char
}
The calculation is detailed in the User Manual.
Now, as to Hyperterminal - it will always embarrass you. Your code can be
perfect, the baudrate clock has zero error, every character is timed perfectly
and STILL Hyperterminal displays junk. The number one reason why I like
developing under Linux is that I hate Hyperterminal under Windows. You might
try TeraTerm or almost anything else.
Richard