Discussion in "ARM Development" started by    shyam    Dec 28, 2007.
Fri Dec 28 2007, 04:46 PM
#11
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
ex
PLLCFG =>PLL0CFG
PLLCON =>PLL0CON
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....

http://www.8051projects.net/forum-t4322-last.html


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

Get Social

Information

Powered by e107 Forum System

Conversation

scena
Wed May 20 2020, 03:59 AM
Does anyone have microcontroller programming software for STC15F104W (core 8051, 4 k, 128 byte, 6 I/O pin, UART ... DIL8), that works?
Sun May 03 2020, 01:08 AM
Tamu Gurung
Hi I am looking for a assembly language program for a digital decimal counter. Time counts max limit of 2 mins starting from 2.00 mins and ending at 0.00. time is to be displayed on 4 7-segment LED displays. Edsim51 simulator to be used. Thanks
Wed Mar 25 2020, 07:09 PM
Tajammul
Sir kindly send the code file i2c for 8051
ExperimenterUK
Sat Mar 14 2020, 04:06 AM
@ Rohitnani,ABEBE..which project ?
Fri Mar 13 2020, 06:25 PM
ABEBE
how can get hadwere of this project
Rohitnani
Sat Mar 07 2020, 09:41 PM
Sir, Could you please send me the zip file input password....
Wed Feb 26 2020, 09:28 PM
Peter Parker
Is it possible to send multiple messages using only 1 GSM module?
Sat Feb 01 2020, 02:42 PM
Pearl Olin
Hello,
Wed Jan 22 2020, 10:46 PM
MINU CHAUDHARY
I m getting errors while simulation process during interfacing socket output and lcd... Can i get the report of ur project which is same as us.
Tue Jan 14 2020, 11:38 AM
shubham kharade
when i am trying to simulate the program in Proteus 8 professional, I am getting some errors as cannot find module file dhtxx.md can u help me

Downloads

Comments

Davidthils
Thu May 21 2020, 08:44 AM
Jakeror
Wed May 20 2020, 09:28 PM
motorCar
Wed May 20 2020, 03:05 PM
Vordrync
Wed May 20 2020, 07:52 AM
JadenjiT
Wed May 20 2020, 03:15 AM
scena
Tue May 19 2020, 06:08 PM
CodySiz
Tue May 19 2020, 02:22 PM
ClaireSat
Mon May 18 2020, 09:50 PM

Online

Guests: 40, Members: 0 ...

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

Members: 38211
Newest member: Davidthils
Forum Activity
xrxx Avatar
Posted By xrxx
Thu Apr 30 2020, 06:59 AM
BCD MULTIPLICATIONAssume that you have to 2 BCD nu...
liqian Avatar
Posted By liqian
Tue Apr 28 2020, 05:26 AM
I happened to see your post and I got many useful ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Apr 28 2020, 04:21 AM
The code is hard to read.Please zip it and attach ...
rogermado Avatar
Posted By rogermado
Sun Apr 26 2020, 01:53 AM
@ExperimenterUK, thanks for your reply. You'll fin...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Apr 25 2020, 05:42 PM
Some simulators handle displays better than others...
rogermado Avatar
Posted By rogermado
Sat Apr 25 2020, 03:59 PM
Hello everyone, sorry in advance if i'm not in the...
PHANTOM28 Avatar
Posted By PHANTOM28
Fri Feb 28 2020, 10:25 AM
Hi.I hope you all can help me. I am relatively ne...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Feb 21 2020, 05:05 PM
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri Feb 21 2020, 04:45 AM
Yes you can do that.1. Create a channel @Thingspea...
ananyagupta Avatar
Posted By ananyagupta
Thu Feb 20 2020, 03:58 AM
With regards to the particular characters sent to ...