EmbeddedRelated.com
Forums

UART0 and UART1 baud rate calculations

Started by dodge1955 February 23, 2006
Has anyone ever done some type of spreadsheet on the different UxDLL
and UxDLM values along with MULVAL and DIVVAL for the most popular
crystals to make the baud rate come out perfect (like 9600, 19200,
etc).  The manual has the examples for 20Mhz, but it would be nice to
have some appendix that has a table of values that come out even for a
variety of commonly used crystals.  11.059Mhz is obviously an easy
one, but others like 12Mhz, 15Mhz, etc. are not as easy and I know
some crystals may not have a perfect value and thus have an error factor.

Sutton - dodge55
	

An Engineer's Guide to the LPC2100 Series

Hi Sutton,

> Has anyone ever done some type of spreadsheet on
the different UxDLL
> and UxDLM values along with MULVAL and DIVVAL for the most popular
> crystals to make the baud rate come out perfect (like 9600, 19200,
> etc).  The manual has the examples for 20Mhz, but it would be nice to
> have some appendix that has a table of values that come out even for a
> variety of commonly used crystals.  11.059Mhz is obviously an easy
> one, but others like 12Mhz, 15Mhz, etc. are not as easy and I know
> some crystals may not have a perfect value and thus have an error factor.

I wrote this utility for the fractional divide enabled UART parts.  It
prints out % error from lowest to highest.  It's not useful for non-fdr
enabled parts.  I'll update in the next week or so for fractional divider
challenged parts.  Perhaps I'll make it a Win32 app as well.

http://groups.yahoo.com/group/lpc2000/files/Tools/lpc2fdcalc.exe
	Joel
	
Crystals that are integer multiples of 1.8432MHz can be used to create
BAUD rates with 0% error.  High/low values for the part & PLL obviously
must be observed.

Regards
-Bill Knight
R O SoftWare
	On Thu, 23 Feb 2006 22:04:59 +0000, dodge1955 wrote:

>Has anyone ever done some type of spreadsheet on
the different UxDLL
>and UxDLM values along with MULVAL and DIVVAL for the most popular
>crystals to make the baud rate come out perfect (like 9600, 19200,
>etc).  The manual has the examples for 20Mhz, but it would be nice to
>have some appendix that has a table of values that come out even for a
>variety of commonly used crystals.  11.059Mhz is obviously an easy
>one, but others like 12Mhz, 15Mhz, etc. are not as easy and I know
>some crystals may not have a perfect value and thus have an error factor.

>Sutton - dodge55
	> 
>Yahoo! Groups Links
	>
	
dodge1955 wrote:

>Has anyone ever done some type of spreadsheet on
the different UxDLL
>and UxDLM values along with MULVAL and DIVVAL for the most popular
>crystals to make the baud rate come out perfect (like 9600, 19200,
>etc).  The manual has the examples for 20Mhz, but it would be nice to
>have some appendix that has a table of values that come out even for a
>variety of commonly used crystals.  11.059Mhz is obviously an easy
>one, but others like 12Mhz, 15Mhz, etc. are not as easy and I know
>some crystals may not have a perfect value and thus have an error factor.
>
>Sutton - dodge55 
>
>  
>
I did a perl script just to calculate errors of the LPC2106 & LPC2138

processors based on crystal frequency:

=============== begin baudrates.pl =================#!/usr/bin/perl
#
# this determines the degree of error between desired and actual
# baudrates on the LPC21xx processors.
#
my $FREQ = 14745000;
my $PLL_MUL = 4;
my $PBSD = 2;
my $CCLK = ($FREQ * $PLL_MUL);
my $PCLK = ($CCLK / $PBSD);
#my $PCLK = 20000000;
my @commonRates (300,600,1200,2400,4800,9600,19200,38400,57600,115200,230400);

#define UART_BAUD(baud) (uint16_t)((PCLK / ((baud) * 16.0)) + 0.5)

sub calcBaud {
my $desired = $_[0];
my $divisor = int(($PCLK / ($desired*16.0))+ 0.5);
my $actual = int(($PCLK / (16*$divisor)) * 1000) / 1000;
my $error = int((($actual - $desired) / $desired) * 1000000) / 10000;
   print "divisor: ${divisor}  desired: ${desired}  ".
      "actual: ${actual}  error: ${error}%\n";
}

   while (@commonRates) {
      calcBaud (shift(@commonRates));

================== snip ======================	-- 
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------
	
Joel Winarske wrote:

>Hi Sutton,
>
>  
>
>>Has anyone ever done some type of spreadsheet on the different UxDLL
>>and UxDLM values along with MULVAL and DIVVAL for the most popular
>>crystals to make the baud rate come out perfect (like 9600, 19200,
>>etc).  The manual has the examples for 20Mhz, but it would be nice to
>>have some appendix that has a table of values that come out even for a
>>variety of commonly used crystals.  11.059Mhz is obviously an easy
>>one, but others like 12Mhz, 15Mhz, etc. are not as easy and I know
>>some crystals may not have a perfect value and thus have an error
factor.
>>    
>>
>
>I wrote this utility for the fractional divide enabled UART parts.  It
>prints out % error from lowest to highest.  It's not useful for non-fdr
>enabled parts.  I'll update in the next week or so for fractional
divider
>challenged parts.  Perhaps I'll make it a Win32 app as well.
>
>  
>
Why?  Why not make it a perl app and then everyone can use it?

Regards,

TomW

-- 
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------
	
Hi Tom,

> >I wrote this utility for the fractional divide
enabled UART parts.  It
> >prints out % error from lowest to highest.  It's not useful for
non-fdr
> >enabled parts.  I'll update in the next week or so for fractional
divider
> >challenged parts.  Perhaps I'll make it a Win32 app as well.
> >
> Why?  Why not make it a perl app and then everyone can use it?

How about as a java swing applet hosted in a web page instead?  Sort of a
spreadsheet style that you can copy data from.  Then anyone with a web
browser can use it.  I am referring to fractional divide calculations. 

Joel
	
Joel Winarske wrote:

>Hi Tom,
>
>  
>
>>>I wrote this utility for the fractional divide enabled UART parts. 
It
>>>prints out % error from lowest to highest.  It's not useful for
non-fdr
>>>enabled parts.  I'll update in the next week or so for
fractional divider
>>>challenged parts.  Perhaps I'll make it a Win32 app as well.
>>>
>>>      
>>>
>>Why?  Why not make it a perl app and then everyone can use it?
>>    
>>
>
>How about as a java swing applet hosted in a web page instead?  Sort of a
>spreadsheet style that you can copy data from.  Then anyone with a web
>browser can use it.  I am referring to fractional divide calculations. 
>
>  
>
Webpage would probably make it more useful than a EXE file.  I do have 
Windows NT running inside VMWare so I can run a couple of apps, but that 
is it.

I was just pointing out that not everyone has Windows on a machine and 
that some of that do don't the latest & greatest (TM - Microsoft).
	TomW
	>Joel
>
>
>
>
> 
>Yahoo! Groups Links
>
>
>
> 
>
>
>  
>
	-- 
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------
	
Hi Sutton,

You might want to look at this LPC214x FractCalc I put together with a
PLL calculator, PDF and ASCII viewers.
It is a Win GUI applet; subject to continuous improvements, but usable.
Check the bottom of this page:
http://www.rogerlynx.com/html/support.html
<http://www.rogerlynx.com/html/support.html>

Hope this helps.

Roger

--- In lpc2000@lpc2..., "dodge1955" <sutton@...> wrote:
>
> Has anyone ever done some type of spreadsheet on the different UxDLL
> and UxDLM values along with MULVAL and DIVVAL for the most popular
> crystals to make the baud rate come out perfect (like 9600, 19200,
> etc).  The manual has the examples for 20Mhz, but it would be nice to
> have some appendix that has a table of values that come out even for a
> variety of commonly used crystals.  11.059Mhz is obviously an easy
> one, but others like 12Mhz, 15Mhz, etc. are not as easy and I know
> some crystals may not have a perfect value and thus have an error
factor.
>
> Sutton - dodge55
>
	
	
I like simple solutions, and I have an Excel solution that also makes 
it easy to see what's going on, and it includes accuracy 
calculations.  

I can email to you if you like 

Kathy Wright
	> 
> --- In lpc2000@lpc2..., "dodge1955"
<sutton@> wrote:
> >
> > Has anyone ever done some type of spreadsheet on the different 
UxDLL
> > and UxDLM values along with MULVAL and DIVVAL
for the most popular
> > crystals to make the baud rate come out perfect (like 9600, 19200,
> > etc).  The manual has the examples for 20Mhz, but it would be 
nice to
> > have some appendix that has a table of values
that come out even 
for a
> > variety of commonly used crystals.  11.059Mhz
is obviously an easy
> > one, but others like 12Mhz, 15Mhz, etc. are not as easy and I know
> > some crystals may not have a perfect value and thus have an error
> factor.
> >
> > Sutton - dodge55
> >
> 
> 
> 
> 
>
	
Hello everyone,

I successfully booted uClinux on LPC2292 with external 4MB flash and
4MB RAM!

But I started kernel only when I load image and romfs with JTAG to RAM
and then start it from that address.

Now I must wrote bootloader. I have functions for initialization of
external memory interfaces, loading images from flash to ram, and that
is OK, but when I want to JUMP to start address of kernel... board
reboots... This is part for jumping to kernel...

---CODE---
void kernel_jump()
{
     void (*kernelstart)(void);

     //KERNEL_START=0x81008000;

     kernelstart = (void (*)(void))KERNEL_START;
     (*kernelstart)();
     
}
-END CODE-

Anyone have idea what is wrong, or some code sample to jump to start
of kernel..., can be in assembler...

thank you in advance
Branko Karaklajic

--
Best regards