EmbeddedRelated.com
Forums

LPC2194 UART BaudRate Problem

Started by Cheng October 13, 2011
I am using LPC2129 CAN QuickStart Board and trying to get UART work. But I found the chip on the board is LPC2194/01, not LPC2129. And I did some research on the LPC2194/01 baudrate setting up for the rev 01 chip. Based on the baudrate calculation in the LPC2194 user manual, I set up the UART0 register as following:

PCLK is 12,000,000 HZ Expected bitrate is 38400

U0LCR = 0x83;

U0DLL = 13;

U0DLM = 0;

U0FDR = 0x00000021; //DIVADDVAL = 1; //MULVAL = 2;

U0LCR = 3;

I spent a whole day to figure this out, and I even tried the UART sample applications from Embedded Artists website, but always got trash data in the terminal.

Any suggestions are welcomed and appreciated. Thank you!

-Tekkon

An Engineer's Guide to the LPC2100 Series

>
> I spent a whole day to figure this out, and I even tried the UART sample applications from Embedded Artists website, but always got trash data in the terminal.
>
> Any suggestions are welcomed and appreciated. Thank you!
>

Storage scope. Tx a char, (eg. 0xAA) and capture it. Measure the bit width, number of bits etc. and then bodge your register values appropriately.

Rgds,
Martin

> PCLK is 12,000,000 HZ Expected bitrate is 38400

Make sure that it is 12 MHz, the APBDIV will control this.
I assume your crystal is 12 MHz and that your are not using the PLL. With the APBDIV set to default you will have a PCLK that is 1/4 of the cpu clock, therefore my guess is that your PCLK is 3MHz.

--
Kevin

--- In l..., "Kevin" wrote:
> > PCLK is 12,000,000 HZ Expected bitrate is 38400
>
> Make sure that it is 12 MHz, the APBDIV will control this.
> I assume your crystal is 12 MHz and that your are not using the PLL. With the APBDIV set to default you will have a PCLK that is 1/4 of the cpu clock, therefore my guess is that your PCLK is 3MHz.
>
> --
> Kevin
>
In the files section you can find 'baudcalc.zip' - a very nice windows program for calculating the various values. There is also baudratecalc.xls - a spreadsheet that finds the optimum values.

Baudcalc gives the values (so does the spreadsheet)
DLL = 0x10
DLM = 0x00
FDR = 0x92

The final baud rate will be 38352 with an error of 0.124 percent.

I haven't actually used baudcalc to get values for my projects but I have used the spreadsheet version and I know it gets the right numbers (at least for my projects).

Richard