EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

LPC2468 UART

Started by metnitin August 26, 2010
Hi,

I am a newbie and trying to drive UART0 of LPC2468 but not able to drive it properly.

Followed following steps:

1. Initialize UART registers
Baud rate : 9600-8-N-1
2. Check the LSR value
3. If LSP value is 0x40 then transmit the character on THR
Can anybody guide me

An Engineer's Guide to the LPC2100 Series

metnitin wrote:
> 2. Check the LSR value
> 3. If LSP value is 0x40 then transmit the character on THR

You don't want to check the value of the register (probably you'll find it
staying at 0x60) but the value of the bit 6 of the register instead (and you
will be even more keen on knowing the value of the bit 5).

--

Timo

Please, don't write me directly. Use the group instead.

nitin gupta wrote:
> Well I have checked that also but in that case also the final output was
> not correct.

So *how* was it incorrect?

Maybe you want to show us your code.

> Do you have any running code?

I think there is many examples in the files section and:

http://tinyurl.com/39okv78

--

Timo
int main()
{
int i;
int j;
char LSRValue;
long ads;

//char c[]="Philips LPC";
IODIR1 = 0x00070000;

Initialize();

//U0THR='A';

i=0;
j=0;
U0TER=0x80;
ads =0;

while(1)
{
LSRValue = U0LSR;
for (ads= 0; ads < 20000; ads++);
if ((LSRValue & 0x40) == 0x40)
{
if(j<10)
{
IOSET1 |= 0x00040000;
U0THR=0x31;//'1';
U2THR='1';
j++;
}
else
{
IOCLR1 |= (0x00040000);
j= ++j % 20;
U0THR=0x32;
U2THR='2';
}
}

if(i<10)
{
//U0THR='1';
i++;
IOSET1 = 0x00030000;
}
if(i>)
{
//U0THR='2';
IOCLR1 = 0x00030000;
i=0;
}

}
}
/*************** System Initialization ***************/
void Initialize()
{
/* Initialize Pin Select Block for Tx and Rx */
//PINSEL0=0x5;
PINSEL0 &= 0xFFFFFF0F;
PINSEL0 |= 0x00000050;

/* Enable FIFO's and reset them */
U0FCR=0x00;

/* Set DLAB and word length set to 8bits */
U0LCR=0x83;

/* Baud rate set to 9600 at crystal 14.74Mhz*/
U0DLM=0x00;
U0DLL=0x60;
/* Clear DLAB */
U0LCR=0x03;
}
This is the code. I am using Keil IDE and 14.75 crystal.

--- On Thu, 26/8/10, t...@gmail.com wrote:

From: t...@gmail.com
Subject: Re: [lpc2000] LPC2468 UART
To: l...
Date: Thursday, 26 August, 2010, 11:52 AM

Please, don't write me directly. Use the group instead.

nitin gupta wrote:
> Well I have checked that also but in that case also the final output was
> not correct.

So *how* was it incorrect?

Maybe you want to show us your code.

> Do you have any running code?

I think there is many examples in the files section and:

http://tinyurl.com/39okv78

--

Timo


Yahoo! Groups Links
nitin gupta wrote:
> This is the code. I am using Keil IDE and 14.75 crystal.

Crystal frequency doesn't tell anything. It is the UART's PCLK frequency that
matters here.

--

Timo

Well I have taken UART PCLK as 14.7456 only.

--- On Thu, 26/8/10, t...@gmail.com wrote:

From: t...@gmail.com
Subject: Re: [lpc2000] LPC2468 UART
To: l...
Date: Thursday, 26 August, 2010, 2:54 PM

 

nitin gupta wrote:

> This is the code. I am using Keil IDE and 14.75 crystal.

Crystal frequency doesn't tell anything. It is the UART's PCLK frequency that

matters here.

--

Timo
nitin gupta wrote:
> Well I have taken UART PCLK as 14.7456 only.

How do you know?

So far, you have not told us, *how* "the final output was not correct".

--

Timo

The final output was not correct because I am not getting the readable characters on serial port emulator i.e hyperterminal as per the code I have written.

--- On Thu, 26/8/10, t...@gmail.com wrote:

From: t...@gmail.com
Subject: Re: [lpc2000] LPC2468 UART
To: l...
Date: Thursday, 26 August, 2010, 4:36 PM

 

nitin gupta wrote:

> Well I have taken UART PCLK as 14.7456 only.

How do you know?

So far, you have not told us, *how* "the final output was not correct".

--

Timo
nitin gupta wrote:
> The final output was not correct because I am not getting the readable
> characters on serial port emulator i.e hyperterminal as per the code I
> have written.

So, you are getting something?

Then, most probable causes are:

The clock frequency of the UART is not like you assume

You have wrong baudrate in hyperterminal

You have bad PC

Your signal levels are not sufficient

You are faced with this one:

http://tech.groups.yahoo.com/group/lpc2000/message/48573

--

Timo


The 2024 Embedded Online Conference