Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

weird problem in UART

weird problem in UART

2006-01-17 by Mauricio Scaff

I have the following problem that is very odd.

I have a very simple program that waits one char from the uart0 and 
sends it back to it.
If I set the baudrate to 57600, it works ok, but if I set the baud rate 
to 115200, the host (PC)  understands any data I send, but the LPC just 
gives Frame errors even if a single byte is sent.....
I'm using a LPC2146 @ 12Mhz
Using these constants in the baud rate generator should give an error of 
0,16%, and the transmission works... Why can't I receive data ?
Thanks, Mauricio


This is the code:

void ser0_init(void)
{
  U0IER = 0;
  U0IIR;
  U0RBR;
  U0LSR;

  U0LCR    = 0x83; // Enable access to divisor latchs

// 57600 @ PERCLK = 12Mhz
//  U0DLL    = 13;
//  U0DLM    = 0;
//  U0FDR    = 1<<4|0; // MulVal[7..4]  DivAddVal[3..0]

// 115200 @ PERCLK = 12Mhz
  U0DLL    = 1;
  U0DLM    = 0;
  U0FDR    = 2<<4|11; // MulVal[7..4]  DivAddVal[3..0]

  U0LCR    = 0x03;  // 8n1
  U0FCR    = 0x87;  // FIFO enabled and cleared; Trigger @ 8 bytes
}

unsigned char ser0_getc (void)
{
  while (!(U0LSR&0x01));  // RDR
  return U0RBR;
}

void ser0_putc(unsigned char ch)
{
  while (!(U0LSR&0x20));  // THRE
  U0THR = ch;
}

int main(void)
{
  Initialize();
  ser0_init();

  ser0_putc('O');
  ser0_putc('k');
  ser0_putc(0x0d);
  ser0_putc(0x0a);
  while (1)
    {
      ser0_putc(ser0_getc());
    }
}

Re: [lpc2000] weird problem in UART

2006-01-17 by Karl Olsen

---- Original Message ----
Show quoted textHide quoted text
From: "Mauricio Scaff" <scaffm@...>
To: <lpc2000@yahoogroups.com>
Sent: Tuesday, January 17, 2006 10:25 PM
Subject: [lpc2000] weird problem in UART

> I have the following problem that is very odd.
>
> I have a very simple program that waits one char from the uart0 and
> sends it back to it.
> If I set the baudrate to 57600, it works ok, but if I set the baud
> rate to 115200, the host (PC)  understands any data I send, but the
> LPC just gives Frame errors even if a single byte is sent.....
> I'm using a LPC2146 @ 12Mhz
> Using these constants in the baud rate generator should give an error
> of 0,16%, and the transmission works... Why can't I receive data ?
> Thanks, Mauricio
>
>
> This is the code:
>
> void ser0_init(void)
> {
>  U0IER = 0;
>  U0IIR;
>  U0RBR;
>  U0LSR;
>
>  U0LCR    = 0x83; // Enable access to divisor latchs
>
> // 57600 @ PERCLK = 12Mhz
> //  U0DLL    = 13;
> //  U0DLM    = 0;
> //  U0FDR    = 1<<4|0; // MulVal[7..4]  DivAddVal[3..0]
>
> // 115200 @ PERCLK = 12Mhz
>  U0DLL    = 1;
>  U0DLM    = 0;
>  U0FDR    = 2<<4|11; // MulVal[7..4]  DivAddVal[3..0]
>
>  U0LCR    = 0x03;  // 8n1
>  U0FCR    = 0x87;  // FIFO enabled and cleared; Trigger @ 8 bytes
> }
> [...]

Others have had similar problems with the fractional baudrate generator and
U0DLL=1, search the archive.

Philips has not documented how the fractional baudrate generator actually
works, other than "This pre-scaler takes the VPB clock and generates an
output clock per specified fractional requirements".  When U0DLL=1, this
output clock is equal to the 16xbaud clock that is used when sampling the
RxD signal.

My guess: If that pre-scaler doesn't spread the extra clocks that it inserts
evenly enough, the RxD circuit might not sample the incoming bits correctly,
and you get wrong bytes or framing errors.

philips_apps, are there any limitations of the fractional baudrate generator
at high baudrates?

Karl Olsen

RE: [lpc2000] weird problem in UART

2006-01-18 by Joel Winarske

Hi Mauricio,

> I have a very simple program that waits one char from the uart0 and
> sends it back to it.
> If I set the baudrate to 57600, it works ok, but if I set the baud rate
> to 115200, the host (PC)  understands any data I send, but the LPC just
> gives Frame errors even if a single byte is sent.....
> I'm using a LPC2146 @ 12Mhz
> Using these constants in the baud rate generator should give an error of
> 0,16%, and the transmission works... Why can't I receive data ?
> Thanks, Mauricio

I've seen issues running at 12MHz as well.  If PLL multiplier is greater
than 1, I have no problems regardless of pclk rate.  If multiplier is 1, or
if the PLL is not enabled, there is not communications.  I've checked 115200
at all possible pclk frequencies, and only had issue with 12MHz.  Perhaps
the equation needs modification to take into account fundamental frequency?



Joel

Re: [lpc2000] weird problem in UART

2006-01-18 by mucko

I have the same problem with baudrates in lpc2138,
when running at 12 mhZ without pll, the baudrate that
i have reached 38400 max. At higher bauds there is no
response!
with pll higher bauds can be reached.

--- Karl Olsen <kro@...> wrote:

> ---- Original Message ----
> From: "Mauricio Scaff" <scaffm@...>
> To: <lpc2000@yahoogroups.com>
> Sent: Tuesday, January 17, 2006 10:25 PM
> Subject: [lpc2000] weird problem in UART
> 
> > I have the following problem that is very odd.
> >
> > I have a very simple program that waits one char
> from the uart0 and
> > sends it back to it.
> > If I set the baudrate to 57600, it works ok, but
> if I set the baud
> > rate to 115200, the host (PC)  understands any
> data I send, but the
> > LPC just gives Frame errors even if a single byte
> is sent.....
> > I'm using a LPC2146 @ 12Mhz
> > Using these constants in the baud rate generator
> should give an error
> > of 0,16%, and the transmission works... Why can't
> I receive data ?
> > Thanks, Mauricio
> >
> >
> > This is the code:
> >
> > void ser0_init(void)
> > {
> >  U0IER = 0;
> >  U0IIR;
> >  U0RBR;
> >  U0LSR;
> >
> >  U0LCR    = 0x83; // Enable access to divisor
> latchs
> >
> > // 57600 @ PERCLK = 12Mhz
> > //  U0DLL    = 13;
> > //  U0DLM    = 0;
> > //  U0FDR    = 1<<4|0; // MulVal[7..4] 
> DivAddVal[3..0]
> >
> > // 115200 @ PERCLK = 12Mhz
> >  U0DLL    = 1;
> >  U0DLM    = 0;
> >  U0FDR    = 2<<4|11; // MulVal[7..4] 
> DivAddVal[3..0]
> >
> >  U0LCR    = 0x03;  // 8n1
> >  U0FCR    = 0x87;  // FIFO enabled and cleared;
> Trigger @ 8 bytes
> > }
> > [...]
> 
> Others have had similar problems with the fractional
> baudrate generator and
> U0DLL=1, search the archive.
> 
> Philips has not documented how the fractional
> baudrate generator actually
> works, other than "This pre-scaler takes the VPB
> clock and generates an
> output clock per specified fractional requirements".
>  When U0DLL=1, this
> output clock is equal to the 16xbaud clock that is
> used when sampling the
> RxD signal.
> 
> My guess: If that pre-scaler doesn't spread the
> extra clocks that it inserts
> evenly enough, the RxD circuit might not sample the
> incoming bits correctly,
> and you get wrong bytes or framing errors.
> 
> philips_apps, are there any limitations of the
> fractional baudrate generator
> at high baudrates?
> 
> Karl Olsen
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.