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..."
----------------------------------------------------Message
Re: [lpc2000] UART0 and UART1 baud rate calculations
2006-02-25 by Tom Walsh
Attachments
- No local attachments were found for this message.