I have used PLL MUL=4 with divisor=22 and It works perfectfly !!
Altouht I don't understand why It doesn't work without multiplie the
clock frequency
Thank you very much !!
--- In lpc2000@yahoogroups.com, Tom Walsh <tom@...> wrote:
>
> icapapindi wrote:
>
> >Can I do it with PLL_MULT=1? I use the Xtal frecuency without PLL, I'm
> >using these values:
> >
> >PCLK = 10 Mhz
> >Divisor = 4
> >MULVAL = 14
> >DIVAddVal = 5
> >
> >With these values It is suppose to get 115.131 bps, but when I test
> >with the oscilloscope the frecuency is about 128 Kbps. The code I
used is:
> >---------------------------------------------------
> >unsigned int divisor=5;
> >UART1_LCR = 0x83; /* 8 bit, 1 stop bit, no parity, enable DLAB */
> >UART1_FDR=(UART1_FDR & 0xFFFFFF00) | 0xE5;
> >UART1_DLL = divisor & 0xFF;
> >UART1_DLM = (divisor >> 8) & 0xFF;
> >UART1_LCR &= ~0x80; /* Disable DLAB */
> >PCB_PINSEL0 = PCB_PINSEL0 & ~0x0F0000 | 0x050000;
> >UART1_FCR = 1;
> >----------------------------------------------------
> >
> >
> >
> I worked my way through the example given in the LPC2138 User Manual
and
> I came up with this little perl program. Perhaps others may find it
useful:
>
> =============== begin baudrate.pl =================
> #!/usr/bin/perl
> # this determines the degree of error between desired and actual
> # baudrates on the LPC2000 processors.
> # UART_BAUD(baud) (uint16_t)((PCLK / ((baud) * 16.0)) + 0.5)
>
> my $FREQ = 14745000; # crystal on X1 X2 pins.
> my $PLL_MUL = 4; # pll mult value.
> my $PBSD = 2; # peripheral bus divider.
> my $CCLK = ($FREQ * $PLL_MUL);
> my $PCLK = ($CCLK / $PBSD);
> my @commonRates =
> (300,600,1200,2400,4800,9600,19200,38400,57600,115200,230400);
>
> 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";
> }
>
> print "Crystal: ${FREQ}\n";
> print "PLL MULT: ${PLL_MUL}\n";
> print "Periph Bus Div: ${PBSD}\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: UART baudrate
2006-03-03 by icapapindi
Attachments
- No local attachments were found for this message.