EmbeddedRelated.com
Forums
Memfault Beyond the Launch

LPC2103 Uart Problem

Started by adriaanswan March 25, 2007
Hi,

I am very new to ARM processors, and as a first simple task I just
want to dump something a pc can read.

I am using Keil uVision 3.5 with RealView compiler.

The processor is a LPC2103, XTAL 19.6608, CCLK 58.9824, M 3, P 2.

I am trying to dump Hello World! to UART0 but nothing. I calculated
U0DLL based on the Phillips application note AN10369. Any Ideas?
Below is the code I am using

#include

void InitUART0(void)
{
PINSEL0 = 0x5;

U0FCR = 0x7;
U0LCR = 0x83;

U0DLL = 0xC0;
U0DLM = 0x0;

U0LCR = 0x3;
}

int main(void)
{
int i;
char c[] = "Hello World!";

InitUART0();

while (1)
{
i = 0;

while (c[i])
{
U0THR = c[i];
i++;
}

U0THR = 0xA;
U0THR = 0xD;

while (!(U0LSR & (1<<6))) {}
}
}

An Engineer's Guide to the LPC2100 Series

Hey Adrian....
Ur code looks correct, wanted to check how are U calculating U baudrate to clock convertion?
I use Clock/(16 * Baudrate)

For Example:
Clock = 12 MHz
Baudrate = 57600
UartCLK = 12 MHz / (16 * 57600) = 13.0208333 = 0x0D
DLL = 0x0D
DLM = 0x00

Of course, I use a LPC2888,as far as I see from Ur code the registers are similar.....to a LPC2103

One important thing that I discovered with my experiment with the UART & plenty of help from Dr.Jaya in this group was that I have to use a NULL-Modem cable.....
here's some lines from my code

inituart(){
FCR = 0xF;
LCR = 0x83;
//DLL = 0x27; // For 19200 BAUD with input clock = 12 MHz
DLL = 0x0D; // For 57600 BAUD with input clock = 12 MHz
DLM = 0x00;
LCR = 0x03;
}

printUART(char a[])
{
int i = 0;
while(a[i]){
THR=a[i];
while(!(LSR & (1<<6))){}
i++;
}

Let me know if this helps

Cheers
-R

----- Original Message ----
From: adriaanswan
To: l...
Sent: Sunday, March 25, 2007 3:48:57 AM
Subject: [lpc2000] LPC2103 Uart Problem

Hi,

I am very new to ARM processors, and as a first simple task I just

want to dump something a pc can read.

I am using Keil uVision 3.5 with RealView compiler.

The processor is a LPC2103, XTAL 19.6608, CCLK 58.9824, M 3, P 2.

I am trying to dump Hello World! to UART0 but nothing. I calculated

U0DLL based on the Phillips application note AN10369. Any Ideas?

Below is the code I am using

#include

void InitUART0(void)

{

PINSEL0 = 0x5;

U0FCR = 0x7;

U0LCR = 0x83;

U0DLL = 0xC0;

U0DLM = 0x0;

U0LCR = 0x3;

}

int main(void)

{

int i;

char c[] = "Hello World!";

InitUART0();

while (1)

{

i = 0;

while (c[i])

{

U0THR = c[i];

i++;

}

U0THR = 0xA;

U0THR = 0xD;

while (!(U0LSR & (1<<6))) {}

}

}



____________________________________________________________________________________
We won't tell. Get more on shows you hate to love
(and love to hate): Yahoo! TV's Guilty Pleasures list.
http://tv.yahoo.com/collections/265
--- In l..., "adriaanswan" wrote:
>
> Hi,
>
> I am very new to ARM processors, and as a first simple task I just
> want to dump something a pc can read.
>
> I am using Keil uVision 3.5 with RealView compiler.
>
> The processor is a LPC2103, XTAL 19.6608, CCLK 58.9824, M 3, P 2.
>
> I am trying to dump Hello World! to UART0 but nothing. I calculated
> U0DLL based on the Phillips application note AN10369. Any Ideas?
> Below is the code I am using
>
> #include void InitUART0(void)
> {
> PINSEL0 = 0x5;
>
> U0FCR = 0x7;
> U0LCR = 0x83;
>
> U0DLL = 0xC0;
> U0DLM = 0x0;
>
> U0LCR = 0x3;
> }
>
> int main(void)
> {
> int i;
> char c[] = "Hello World!";
>
> InitUART0();
>
> while (1)
> {
> i = 0;
>
> while (c[i])
> {
> U0THR = c[i];
> i++;
> }
>
> U0THR = 0xA;
> U0THR = 0xD;
>
> while (!(U0LSR & (1<<6))) {}
> }
> }
>
Hi,
You should check the status register after transmitting each byte.
Try changing the code as below.

while (c[i])
{
U0THR = c[i];
while (!(U0LSR & (1<<6))) {}
i++;
}

Also, at what baud rate is the PC application set ?
Hi,

Thanks for the info, but still no luck. PC is set to 9600. I am
starting to think it is my settings in Keil.

Does anyone know what the following settings have to be?

Target options dialog, Target tab
IROM1 and IRAM1

And same dialog, under Linker tab
R/O Base and R/W Base

Thanks,
Adriaan
--- In l..., "Lekha" wrote:
> Hi,
> You should check the status register after transmitting each
byte.
> Try changing the code as below.
>
> while (c[i])
> {
> U0THR = c[i];
> while (!(U0LSR & (1<<6))) {}
> i++;
> }
>
> Also, at what baud rate is the PC application set ?
>
For an LPC2103 I believe they should be:

Target Tab:
IROM1 = start 0x0 size 0x8000
IRAM1 = start 0x40000000 size 0x2000

Linker Tab:
R/O Base: 0x0
R/W Base: 0x40000000

Although I've just checked and that's the defaults my version of microvision
has set already. I can't quite see how this will impact directly on your
UART though? It's simply the definition of where your memory is and the size
of it.

Andy

-----Original Message-----
From: l... [mailto:l...]On Behalf Of
adriaanswan
Sent: 26 March 2007 11:16
To: l...
Subject: [lpc2000] Re: LPC2103 Uart Problem
Hi,

Thanks for the info, but still no luck. PC is set to 9600. I am
starting to think it is my settings in Keil.

Does anyone know what the following settings have to be?

Target options dialog, Target tab
IROM1 and IRAM1

And same dialog, under Linker tab
R/O Base and R/W Base

Thanks,
Adriaan

--- In l..., "Lekha" wrote:
> Hi,
> You should check the status register after transmitting each
byte.
> Try changing the code as below.
>
> while (c[i])
> {
> U0THR = c[i];
> while (!(U0LSR & (1<<6))) {}
> i++;
> }
>
> Also, at what baud rate is the PC application set ?
>
When I download the sample binaries everything is fine, but when I
compile the same code and download the binaries nothing happend.

I had the IRAM and R/W Base at 0x4000000 and not 0x40000000, big
diffirence one 0 makes.

Thanks for the help.

--- In l..., "Andrew Berney" wrote:
>
> For an LPC2103 I believe they should be:
>
> Target Tab:
> IROM1 = start 0x0 size 0x8000
> IRAM1 = start 0x40000000 size 0x2000
>
> Linker Tab:
> R/O Base: 0x0
> R/W Base: 0x40000000
>
> Although I've just checked and that's the defaults my version of
microvision
> has set already. I can't quite see how this will impact directly on
your
> UART though? It's simply the definition of where your memory is and
the size
> of it.
>
> Andy
>
> -----Original Message-----
> From: l... [mailto:l...]On
Behalf Of
> adriaanswan
> Sent: 26 March 2007 11:16
> To: l...
> Subject: [lpc2000] Re: LPC2103 Uart Problem
> Hi,
>
> Thanks for the info, but still no luck. PC is set to 9600. I am
> starting to think it is my settings in Keil.
>
> Does anyone know what the following settings have to be?
>
> Target options dialog, Target tab
> IROM1 and IRAM1
>
> And same dialog, under Linker tab
> R/O Base and R/W Base
>
> Thanks,
> Adriaan
>
> --- In l..., "Lekha" wrote:
> > Hi,
> > You should check the status register after transmitting each
> byte.
> > Try changing the code as below.
> >
> > while (c[i])
> > {
> > U0THR = c[i];
> > while (!(U0LSR & (1<<6))) {}
> > i++;
> > }
> >
> > Also, at what baud rate is the PC application set ?
> >
>
>

Memfault Beyond the Launch