Discussion in "ARM Development" started by    shyam    Dec 28, 2007.
Fri Dec 28 2007, 09:46 PM
now since the pll has been set to operate at a frequency say 60Mhz...
we can start using the inbuilt devices... the first one is UART

first of all let us initialise our uart to a desired baudrate

BAUDRATE = PCLK /( (16*(256*U0DLM+U0DLL)) (1+ (DivAddVal/MulVal)) )

PCLK is the clock frequency generated from the PLL DLM & DLL each are 8 bit registers required to divide the clock to desired frequency.... for further fine tuning of the baud rate we have DivAddVal
and mulVal registers

The UART0 Divisor Latch is part of the UART0 Fractional Baud Rate Generator and holds
the value used to divide the clock supplied by the fractional prescaler in order to produce
the baud rate clock, which must be 16x the desired baud rate (Equation 9–1). The U0DLL
and U0DLM registers together form a 16 bit divisor where U0DLL contains the lower 8 bits
of the divisor and U0DLM contains the higher 8 bits of the divisor. A 0x0000 value is
treated like a 0x0001 value as division by zero is not allowed

assuming PCLK = 60Mhz assuming no fine tuning required...
for a baud rate of 115200 lets find out the values of DLL and DLM remember it will be easier if ou consider DLL and DLM a single 16 bit register instead of 2 8 bit register .. with the higher byte going to DLM

=> (256*U0DLM+U0DLL) = 60,000,000/(16*115200) = 32.552 =>0x0020 hex
=> DLM = 0x00
DLL = 0x20
so we can calculate the values required for any baud rate!!!!
try out to find the maximum baud rate you can generate in LPC214X (remember division by zero not possible in LPC214x ... the zero in final expression(denominator) will automatically be taken as +1).

consider the following funtion void init_uart0(void)

u will find a new register U0LCR refer manual u will find =>

bit7 DLAB
bit6 Set Break
bit5 StickParity
bit4 EvenPar.Selct.
bit3 ParityEnable
bit2 No. ofStop Bits
bit1 bit0 Word Length Select

for 8 bit no parity 1 stop bit... from manual
bit0 =1
bit1 =1
bit 2 =0
bit 3=0
bit 7 (dlab) =1
U0LCR =0x83 or U0LCR =0x80 ; U0LCR=0x03;

The Divisor Latch Access Bit (DLAB) in U0LCR must be zero in order to access the
U0THR(transmit hold register)/U0RBR (receive buffer register) and must be one when updating values of DLL DLM....

so we have...
void init_uart0(void)
U0LCR = 0;      // DLAB = 0
U0LCR = 0x80;   // DLAB = 1
U0DLM = 0x00;   // DLM = 0x00
U0DLL = 0x20;   // DLL = 0x20, Divisor = 32, set baudrate=115200
U0LCR = 0x03;   // DLAB = 0, No parity, 8 data, 1 stop
int putchar (int ch) /* Write character to Serial Port */
if (ch == '\n')
       while (!(U0LSR & 0x20));
      U0THR = CR; /* output CR */
while (!(U0LSR & 0x20));
return (U0THR = ch);
int getchar (void) /* Read character from Serial Port */
while (!(U0LSR & 0x01));
return (U0RBR);

we will next discuss the above code!! till then bye :bye

for users referring to user manual for lpc214x series please note:
PLL in all above discussion shall be veiwed as PLL0 similarly all registers will change
the second PLL will be discussed under the topic USB!! till then no mention of PLL1 registers
also the name of registers may change according to the header files used ex. most lpc210x.h headers will have SCB_PLLCFG instead of PLLCFG.

please post your doubts (UART) here....


[ Edited Sat Dec 29 2007, 06:09 PM ]

Get Social


Powered by e107 Forum System


Tue May 04 2021, 08:34 PM
Hi there! I could have sworn I've been to this site before but after browsing through some of the post I realized it's new to me. Anyways, I'm definitely glad I found it and I'll be book-marking and checking back frequently! check my score https://creditscorecheckn.com
Tue May 04 2021, 06:39 PM
What's up everyone, it's my first go to see at this web page, and post is really fruitful in support of me, keep up posting these types of articles. Best Credit Score https://creditscoresids.com
Tue May 04 2021, 01:13 PM
What's up to all, the contents present at this site are really remarkable for people knowledge, well, keep up the good work fellows. karma credit score https://getcreditscoreww.com
Tue May 04 2021, 09:49 AM
I like the helpful info you provide in your articles. I will bookmark your blog and check again here frequently. I am quite certain I'll learn many new stuff right here! Good luck for the next! check credit report https://creditreportuss.com
Tue May 04 2021, 06:28 AM
I am not sure where you are getting your info, but great topic. I needs to spend some time learning more or understanding more. Thanks for wonderful information I was looking for this info for my mission. monthly credit report https://checkcreditscore24.com



Thu Jun 25 2020, 03:46 PM
Mon Jun 22 2020, 03:03 PM
Tue Jun 16 2020, 05:10 PM
Sat Jun 13 2020, 09:43 PM
Thu May 21 2020, 12:44 PM
Thu May 21 2020, 01:28 AM
Wed May 20 2020, 07:05 PM
Wed May 20 2020, 11:52 AM


Guests: 51, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38215
Newest member: Mirza123