Forums

LPC2129 & UART1

Started by tsyrjala2 November 16, 2005
Hello,

I am quite new with these ARM based controllers. I've been trying to
get the uart working with code from Philips application note AN10369.

-------------cut-------------------------cut-----------------

#include "lpc21xx.h"

void Initialize(void);

#define TEMT (1<<6)
#define LINE_FEED 0xA
#define CARRIAGE_RET 0xD

int main()
{
int i;
char c[]="Philips";

PINSEL0=0x5;

U0FCR=0x7;

U0LCR=0x83;

U0DLL=0x18;
U0DLM=0x0;

U0LCR=0x3;

while(1)
{
i=0;

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

U0THR=LINE_FEED;
U0THRRIAGE_RET;

while(!(U1LSR & TEMT)) {}
} //end of while(1)

} //end of main

-cut--------------------------cut-----------------

Getting uart working should be simple job, but I'm unable get any life
into it.

--
Tim



An Engineer's Guide to the LPC2100 Series

Hi Tim,

> Getting uart working should be simple job, but I'm unable get any life
> into it.

I ran your code snippet on one of my boards, your code's fine. Perhaps
there's an issue with your debug environment?

Joel


--- In lpc2000@lpc2..., "Joel Winarske" <joelw@i...> wrote:
>
> Hi Tim,
>
> > Getting uart working should be simple job, but I'm unable get any life
> > into it.
>
> I ran your code snippet on one of my boards, your code's fine. Perhaps
> there's an issue with your debug environment?

Hello Joel,

I am using Olimex LPC-E2129 development board and WinARM compiler.

When I connect oscilloscope to TX1 pin, it only shows logical 1.
Could it be problem with the divider or something else?

--
Tim



> Hello Joel,
>
> I am using Olimex LPC-E2129 development board and WinARM compiler.
>
> When I connect oscilloscope to TX1 pin, it only shows logical 1.
> Could it be problem with the divider or something else?

If you are not running any code prior to main, other than CRT startup:

On power up the peripheral clock is 1/4 of the clock frequency. See
register VPBDIV.

Even if the divider is not correct you should still see a wiggle on the tx
pin.

Your code works on my IAR LPC2148 board. I dropped the code in prior to
clock setup, and changed the baud pre-scaler to match my crystal.

My point on debug environment:
If you're trying to debug from RAM, be sure you're setting MEMMAP correctly.
If it's quicker to run code from flash and not fool with MEMAP try that.
Either way you need to have your debug environment setup correctly or
nothing may appear to run. Joel