<?xml version="1.0" encoding="utf-8"?>
				<!-- generator="e107" -->
				<!-- content type="Forum / topic" -->
				<rss  version="2.0">
				<channel>
				<title>8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes : Forum / topic</title>
				<link>http://www.8051projects.net/</link>
				<description>Learn to make simple microcontroller projects, pic, 8051, avr and arm projects. download 8051 projects, tutorials, libraries, sample codes. join the microcontroller discussion forum and ask doubts regarding electronics. the best source for 8051 over internet.</description>

<language>en-gb</language>
				<copyright><a rel="license" href="http://creativecommons.org/licenses/by-nc/2.5/in/" target="_blank"><img alt="Creative Commons License" width="80" height="15" style="border-width:0" src="http://i.creativecommons.org/l/by-nc/2.5/in/80x15.png" target="_blank" /></a>This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc/2.5/in/" target="_blank">Creative Commons Attribution-Noncommercial 2.5 India License</a>.<a href='http://www.8051projects.net/disclaimer.htm' target='_blank' />Rickey's World Disclaimer</a></copyright>
				<managingEditor>Ajay Bhargav - contact@nospam.com</managingEditor>
				<webMaster>contact@nospam.com</webMaster>
				<pubDate>Mon, 01 Dec 2008 13:33:43 -0800</pubDate>
				<lastBuildDate>Mon, 01 Dec 2008 13:33:43 -0800</lastBuildDate>
				<docs>http://backend.userland.com/rss</docs>
				<generator>e107 (http://e107.org)</generator>
				<ttl>60</ttl>
				<textInput>
				<title>Search</title>
				<description>Search 8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes</description>
				<name>query</name>
				<link>http://www.8051projects.net/search.php</link>
				</textInput>
						<item>
						<title>ARM tutorial :  UART</title>
<link>http://www.8051projects.net/forum-t4311.html</link>
<description><![CDATA[topics to be discussed<br />1. selction of pins for different function.<br />2. setting PLL .<br />3.setting baud rate.<br />4.sending a byte of data.<br />5. receiving a byte of data.<br />6. using in interrupt.<br />7.difference between polled and interrupt mode <br /><br /><br />any thing u wanna add??]]></description>
<pubDate>Fri, 28 Dec 2007 07:34:23 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t4311.html</guid>
</item>
						<item>
						<title>Re: ARM tutorial :  UART</title>
<link>http://www.8051projects.net/forum-t4311.html</link>
<description><![CDATA[A small example programme to learn and test communication on hyperterminal . If till tomorrow i i could understand and test it on my board then i will feel bit satisfied <br />I believe you have made a proper list of topics further .<br /><br /><div class=''>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="c" style="font-family: monospace;"><span style="color: #808080; font-style: italic;">/* Include header file depending upon device been used */</span><br /><span style="color: #339933;">#include&lt;Philips\LPC2148.h&gt;</span><br /><span style="color: #993333;">void</span> Initialize<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span><span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #808080; font-style: italic;">/* Macro Definitions */</span><br /><span style="color: #339933;">#define TEMT (1&lt;&lt;6)</span><br /><span style="color: #339933;">#define LINE_FEED 0xA</span><br /><span style="color: #339933;">#define CARRIAGE_RET 0xD</span><br /><span style="color: #808080; font-style: italic;">/************************* MAIN *************************/</span><br /><span style="color: #993333;">int</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br /><span style="color: #993333;">int</span> i;<br /><span style="color: #993333;">char</span> c<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>=<span style="color: #ff0000;">&quot;Philips LPC&quot;</span>;<br />Initialize<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #808080; font-style: italic;">/* Print forever */</span><br /><span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br />i=<span style="color: #cc66cc;">0</span>;<br /><span style="color: #808080; font-style: italic;">/* Keep Transmitting until Null character('\0') is reached */</span><br /><span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>c<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br />U0THR=c<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;<br />i++;<br /><span style="color: #66cc66;">&#125;</span><br />U0THR=LINE_FEED;<br />U0THR=CARRAIGE_RET;<br /><span style="color: #808080; font-style: italic;">/* Wait till U0THR and U0TSR are both empty */</span><br /><span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>!<span style="color: #66cc66;">&#40;</span>U0LSR &amp; TEMT<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><span style="color: #808080; font-style: italic;">/*************** System Initialization ***************/</span><br /><span style="color: #993333;">void</span> Initialize<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br /><span style="color: #808080; font-style: italic;">/* Initialize Pin Select Block for Tx and Rx */</span><br />PINSEL0=0x5;<br /><span style="color: #808080; font-style: italic;">/* Enable FIFO's and reset them */</span><br />U0FCR=0x7;<br /><span style="color: #808080; font-style: italic;">/* Set DLAB and word length set to 8bits */</span><br />U0LCR=0x83;<br /><span style="color: #808080; font-style: italic;">/* Baud rate set to 9600 */</span><br />U0DLL=0x10;<br />U0DLM=0x0;<br /><span style="color: #808080; font-style: italic;">/* Clear DLAB */</span><br />U0LCR=0x3;<br /><span style="color: #66cc66;">&#125;</span><br /><span style="color: #808080; font-style: italic;">/*********************************************************/</span><br /><br /><br />&nbsp;</div></div><br /><br />]]></description>
<author>vinay1277&lt;jpss1277@nospam.com&gt;</author>
<pubDate>Fri, 28 Dec 2007 07:58:13 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t4311.html</guid>
</item>
						<item>
						<title>Re: ARM tutorial :  UART</title>
<link>http://www.8051projects.net/forum-t4311.html</link>
<description><![CDATA[Slow and steady wins the race . You be slow and i am going to be steady . Ultimately we all will win.]]></description>
<author>vinay1277&lt;jpss1277@nospam.com&gt;</author>
<pubDate>Fri, 28 Dec 2007 09:13:34 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t4311.html</guid>
</item>
						<item>
						<title>Re: ARM tutorial :  UART</title>
<link>http://www.8051projects.net/forum-t4311.html</link>
<description><![CDATA[I am looking forward for elaborate explanation on above subtopics . I do miss a lot words while typing a post and send it without checking . Please ignore myomissions.]]></description>
<author>vinay1277&lt;jpss1277@nospam.com&gt;</author>
<pubDate>Fri, 28 Dec 2007 08:01:22 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t4311.html</guid>
</item>
						<item>
						<title>Re: ARM tutorial :  UART</title>
<link>http://www.8051projects.net/forum-t4311.html</link>
<description><![CDATA[<br />wow u r really being quick i wud prefer to take a step a time...<br />moreover it is always better to set PLL than using its default value....<br /><br />we will certainly try to get ur programme running....<br /><br /><strong class='bbcode bold'>1. selction of pins for different function.</strong><br /><br />in lpc as u might have noticed one pin can be configured to serve as 4 different funtions  ex.<br />P0.1/RXD0/PWM3/EINT0   it is one single pin..<br /><br />these functions lets say are fun0 fun1 fun2 fun3.<br /><br />edited[<br />P1 in lpc21xx donot have special functions they have just fun0 and fun1.<br />things to note:  we r not considering JTAG yet..   actually PINSEL2 is the PINSEL associated for P1 but<br />fun1 is related for JTAG debug.. Pins 0 through 15 of port 1 are not available.<br />]<br />in all cases  fun0 is GPIO<br /><br />by default (unless the functionality is selected  all pins have this fun0).<br />the functionality can be configured by using PINSEL register (32 bit).<br /><br />edited<br />[<br /><br /><div class='indent'>thus it wud be clear by now that P1 does not have a PINSEL corresponding to it....<br />oops!! forgot pinsel2   plz ignore this line  <img src='http://www.8051projects.net/e107_images/emotes/yahoo/9.gif' alt='' style='vertical-align:middle; border:0' />   </div><br />]<br />in binary the functions can be numbered as 0  00<br />                                                                      1  01<br />                                                                      2 02<br />                                                                      3 03<br />each pin thus has two pinsel bits corresponding to it..<br />thus it wud be clear now ..  for 32 bit Port 1   2 PINSEL registers wud be required..<br />they are PINSEL0 &amp; PINSEL1.<br /><br />now to ajay's code.     <br /><br /> <div class=''>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="c" style="font-family: monospace;"><br /><span style="color: #993333;">void</span> Initialize<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br /><span style="color: #808080; font-style: italic;">/* Initialize Pin Select Block for Tx and Rx */</span><br />PINSEL0=0x5;<br />&nbsp;</div></div> <br /><br />writing 0x5 in binary  we get..    0x 01 01<br />the first two bits determine the function chosen <br />for P0.0  i.e. fun1  => UART0 TXD0<br />similarly the next two  bits determine <br />the function chosen <br />for P0.1  i.e. fun1  => UART0 RXD0<br /><br />thus ajay has selected his pair of RX/TX <br /> <img src='http://www.8051projects.net/e107_images/emotes/yahoo/69.gif' alt='' style='vertical-align:middle; border:0' />  <br /> <img src='http://www.8051projects.net/e107_images/emotes/yahoo/69.gif' alt='' style='vertical-align:middle; border:0' />   <img src='http://www.8051projects.net/e107_images/emotes/yahoo/69.gif' alt='' style='vertical-align:middle; border:0' />]]></description>
<author>shyam&lt;shyam@nospam.com&gt;</author>
<pubDate>Fri, 28 Dec 2007 08:46:29 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t4311.html</guid>
</item>
						<item>
						<title>Re: ARM tutorial :  UART</title>
<link>http://www.8051projects.net/forum-t4311.html</link>
<description><![CDATA[@vinay<br />please go through this page<br /><a class='bbcode' href='http://www.8051projects.net/out.php?link=http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/WinARM_20060117_readme.html' rel='external'  target='_blank'>http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/WinARM_20060117_readme.html</a><br />]]></description>
<author>shyam&lt;shyam@nospam.com&gt;</author>
<pubDate>Fri, 28 Dec 2007 09:51:51 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t4311.html</guid>
</item>
						<item>
						<title>Re: ARM tutorial :  UART</title>
<link>http://www.8051projects.net/forum-t4311.html</link>
<description><![CDATA[please note P0.31 is GPO Port only  i.e. cannot be configured as input!<br />it is generally used as USB good link led signal!!]]></description>
<author>shyam&lt;shyam@nospam.com&gt;</author>
<pubDate>Fri, 28 Dec 2007 10:07:31 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t4311.html</guid>
</item>
						<item>
						<title>Re: ARM tutorial :  UART</title>
<link>http://www.8051projects.net/forum-t4311.html</link>
<description><![CDATA[<strong class='bbcode bold'>2. setting PLL .</strong><br /><br /><div class='indent'>The PLL is used to multiply the external crystal frequency up to the maximum 60 MHz. It<br />is controlled by the constants M and P.<br /><br /><br />Within the PLL are two constants which must be programmed in order to determine the clock for the CPU and AHB. This clock is called Cclk. The first constant is a straightforward multiplier of the external crystal. The output frequency of the PLL is given by:<br />Cclk = M x Osc<br /><br /><br />In the feedback path of the PLL is a current-controlled oscillator which must operate in the range 156MHz – 320<br />MHz.. The second constant acts as a programmable divider which ensures that the CCO is kept in specification.<br />The operating frequency of the CCO is defined as:<br />Fcco = Cclk x 2 x P</div><br /><br />well i had already submitted a design for lpc2138/48   if u find it ... u wud notice the crystall of frequency 14.745 Mhz.<br /><br /><br />so  <br />- System should run at max. Frequency (60MHz) [limit: max 60 MHz]<br />   - Choose multiplier M=4 <br />     so cclk = M * F_OSC= 4 * 14745000Hz = 58980000 Hz<br /><br /> - F_CCO must be inbetween the limits 156 MHz to 320 MHz<br />     datasheet: F_CCO = F_OSC * M * 2 * P<br />   - choose devider P=2 => F_CCO = 14745000Hz * 4 * 2 * 2<br />     = 235920000 ~=236 MHz<br /><br />now you can choose the multiplier and devider value for PLL depending on your crystall<br />]]></description>
<author>shyam&lt;shyam@nospam.com&gt;</author>
<pubDate>Fri, 28 Dec 2007 10:25:55 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t4311.html</guid>
</item>
						<item>
						<title>Re: ARM tutorial :  UART</title>
<link>http://www.8051projects.net/forum-t4311.html</link>
<description><![CDATA[please note:<br /><br /> <div class='indent'><br />There are two PLL modules in the LPC2141/2/4/6/8 microcontroller. The PLL0 is used to<br />generate the CCLK clock (system clock) while the PLL1 has to supply the clock for the<br />USB at the fixed rate of 48 MHz. Structurally these two PLLs are identical with exception<br />of the PLL interrupt capabilities reserved only for the PLL0.<br /></div> <br /><br />so @ ajay...<br />u should configure the PLL first...<br /><br />lets see how to do it=>>><br /><br />]]></description>
<author>shyam&lt;shyam@nospam.com&gt;</author>
<pubDate>Fri, 28 Dec 2007 10:58:29 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t4311.html</guid>
</item>
						<item>
						<title>Re: ARM tutorial :  UART</title>
<link>http://www.8051projects.net/forum-t4311.html</link>
<description><![CDATA[take a look at the code...<br /><br /><div class=''>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="c" style="font-family: monospace;"><br /><span style="color: #339933;">#define FOSC&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 14745000 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br />&nbsp;<span style="color: #808080; font-style: italic;">/*on board crystall frequency */</span><br /><span style="color: #339933;">#define PLL_M&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; 4&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br />&nbsp;<span style="color: #808080; font-style: italic;">/*Cclk = M x Osc &nbsp;Cclk =60Mhz &nbsp;Osc 14.745 Mhz M~4 &nbsp; */</span><br /><span style="color: #339933;">#define MSEL&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (PLL_M-1)</span><br /><span style="color: #339933;">#define PSEL0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 5 &nbsp; &nbsp; &nbsp; </span><br />&nbsp;<span style="color: #808080; font-style: italic;">/*see user manual PLLCFG*/</span><br /><span style="color: #339933;">#define PSEL1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 6 &nbsp; </span><br />&nbsp;<span style="color: #808080; font-style: italic;">/*see user manual*/</span><br /><br /><span style="color: #339933;">#define PLLE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0</span><br />&nbsp;<span style="color: #808080; font-style: italic;">/*see user manual PLLCON*/</span><br /><span style="color: #339933;">#define PLLC&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp; &nbsp; </span><br />&nbsp;<span style="color: #808080; font-style: italic;">/*see user manual PLLCON*/</span><br /><br /><span style="color: #339933;">#define PLOCK&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; 10 &nbsp; </span><br />&nbsp;<span style="color: #808080; font-style: italic;">/*see user manual PLLSTAT*/</span><br /><br /><span style="color: #339933;">#define PLL_FEED1&nbsp; &nbsp; &nbsp; &nbsp;0xAA &nbsp; </span><br />&nbsp;<span style="color: #808080; font-style: italic;">/*constant*/</span><br /><span style="color: #339933;">#define PLL_FEED2&nbsp; &nbsp; &nbsp; &nbsp;0x55 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><br />&nbsp;<span style="color: #808080; font-style: italic;">/*constant*/</span><br /><br /><br /><span style="color: #993333;">void</span> systemPllInit<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// --- enable and connect the PLL (Phase Locked Loop) ---</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// a. set multiplier and divider</span><br />&nbsp; &nbsp; &nbsp; &nbsp; PLLCFG = MSEL | <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>&lt;&lt;PSEL1<span style="color: #66cc66;">&#41;</span> | <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>&lt;&lt;PSEL0<span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// b. enable PLL</span><br />&nbsp; &nbsp; &nbsp; &nbsp; PLLCON = <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>&lt;&lt;PLLE<span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// c. feed sequence</span><br />&nbsp; &nbsp; &nbsp; &nbsp; PLLFEED = PLL_FEED1;<br />&nbsp; &nbsp; &nbsp; &nbsp; PLLFEED = PLL_FEED2;<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// d. wait for PLL lock (PLOCK bit is set if locked)</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>!<span style="color: #66cc66;">&#40;</span>PLLSTAT &amp; <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>&lt;&lt;PLOCK<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// e. connect (and enable) PLL</span><br />&nbsp; &nbsp; &nbsp; &nbsp; PLLCON = <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>&lt;&lt;PLLE<span style="color: #66cc66;">&#41;</span> | <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>&lt;&lt;PLLC<span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// f. feed sequence</span><br />&nbsp; &nbsp; &nbsp; &nbsp; PLLFEED = PLL_FEED1;<br />&nbsp; &nbsp; &nbsp; &nbsp; PLLFEED = PLL_FEED2;<br />&nbsp; &nbsp; &nbsp; &nbsp;<br /><span style="color: #66cc66;">&#125;</span><br />&nbsp;</div></div><br /><br />steps to initialise pll  <br /><strong class='bbcode bold'>1. </strong><br />        // --- enable and connect the PLL (Phase Locked Loop) ---<br />	// a. set multiplier and divider<br />	PLLCFG = MSEL | (1&lt;&lt;PSEL1) | (0&lt;&lt;PSEL0);<br />remember MSEL = M -1 cause to remove devide by zero error... the MSEL value is always +1 there will be other instances too... we will discuss as they come across..<br /><strong class='bbcode bold'>2.</strong><br />       // b. enable PLL<br />	PLLCON = (1&lt;&lt;PLLE);<br />every time you make a change in PLLCON register be sure to follow it up with a feed sequence to affect the changes done... else there wud be no effect  and old status will be in  effect...  <img src='http://www.8051projects.net/e107_images/emotes/yahoo/1.gif' alt='' style='vertical-align:middle; border:0' />  <br />so..<br />        // c. feed sequence<br />	PLLFEED = PLL_FEED1;<br />	PLLFEED = PLL_FEED2;//mandatory<br /><strong class='bbcode bold'>3.</strong><br />       // d. wait for PLL lock (PLOCK bit is set if locked)<br />	while (!(PLLSTAT &amp; (1&lt;&lt;PLOCK)));<br /><strong class='bbcode bold'>4.</strong><br />       // e. connect (and enable) PLL<br />	PLLCON = (1&lt;&lt;PLLE) | (1&lt;&lt;PLLC);<br />	// f. feed sequence<br />	PLLFEED = PLL_FEED1;<br />	PLLFEED = PLL_FEED2;<br />  <br />now your system is ready to work at the desired PLL frequencies...   remember PLL settings shud be carefully done... as they help generate the frequencies for almost all on chip devices...<br /><br />note: dont worry writing this function in your every code..  it will remain same as long as u use the same crystall...<br /><br />]]></description>
<author>shyam&lt;shyam@nospam.com&gt;</author>
<pubDate>Fri, 28 Dec 2007 11:57:20 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t4311.html</guid>
</item>
						<item>
						<title>Re: ARM tutorial :  UART</title>
<link>http://www.8051projects.net/forum-t4311.html</link>
<description><![CDATA[now since the pll has been set to operate at a frequency say 60Mhz...<br />we can start using the inbuilt devices... the first one is UART<br /><br />first of all let us initialise our uart to a desired baudrate<br /><br /><div class='indent'><strong class='bbcode bold'>BAUDRATE = PCLK /(   (16*(256*U0DLM+U0DLL))  (1+  (DivAddVal/MulVal))  )<br /></strong></div><br /><br />PCLK is the clock frequency generated from the PLL DLM &amp; 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      <br />and   mulVal registers<br /><br /><br /> <div class='indent'><br />The UART0 Divisor Latch is part of the UART0 Fractional Baud Rate Generator and holds<br />the value used to divide the clock supplied by the fractional prescaler in order to produce<br />the baud rate clock, which must be 16x the desired baud rate (Equation 9–1). The U0DLL<br />and U0DLM registers together form a 16 bit divisor where U0DLL contains the lower 8 bits<br />of the divisor and U0DLM contains the higher 8 bits of the divisor.<strong class='bbcode bold'> A 0x0000 value is<br />treated like a 0x0001 value as division by zero is not allowed</strong><br /></div> <br /><br />assuming PCLK = 60Mhz  assuming no fine tuning required...<br />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<br /><br />=> (256*U0DLM+U0DLL) = 60,000,000/(16*115200) = 32.552 =>0x0020 hex<br />=> DLM = 0x00<br />      DLL = 0x20<br />so we can calculate the values required for any baud rate!!!!<br />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).<br /><br />consider the following funtion <strong class='bbcode bold'>void init_uart0(void)</strong><br /><br />u will find a new register U0LCR  refer manual u will find  =><br /> <div class='indent'><br /><strong class='bbcode bold'><br />bit7               DLAB<br /> bit6              Set Break  <br /> bit5              StickParity   <br />bit4               EvenPar.Selct.   <br />bit3               ParityEnable   <br />bit2               No. ofStop Bits   <br />bit1   bit0      Word Length Select          <br /></strong><br /></div> <br /><br />for 8 bit no parity 1 stop bit... from manual<br />bit0 =1<br />bit1 =1<br />bit 2 =0<br />bit 3=0<br />bit 7  (dlab) =1<br />=><br /> U0LCR =0x83     or   U0LCR =0x80 ; U0LCR=0x03;<br /><div class='indent'>The Divisor Latch Access Bit (DLAB) in U0LCR must be zero in order to access the<br />U0THR(transmit hold register)/U0RBR (receive buffer register)   and must be one when updating values of DLL DLM....</div><br /><br /><br />so we have...<br /><div class=''>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="c" style="font-family: monospace;"><br /><span style="color: #993333;">void</span> init_uart0<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br />U0LCR = <span style="color: #cc66cc;">0</span>; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// DLAB = 0</span><br />U0LCR = 0x80; &nbsp; <span style="color: #808080; font-style: italic;">// DLAB = 1</span><br />U0DLM = 0x00; &nbsp; <span style="color: #808080; font-style: italic;">// DLM = 0x00</span><br />U0DLL = 0x20; &nbsp; <span style="color: #808080; font-style: italic;">// DLL = 0x20, Divisor = 32, set baudrate=115200</span><br />U0LCR = 0x03; &nbsp; <span style="color: #808080; font-style: italic;">// DLAB = 0, No parity, 8 data, 1 stop</span><br /><span style="color: #66cc66;">&#125;</span><br /><span style="color: #993333;">int</span> putchar <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> ch<span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">/* Write character to Serial Port */</span><br /><span style="color: #66cc66;">&#123;</span><br /><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>ch == <span style="color: #ff0000;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #66cc66;">&#41;</span><br />&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>!<span style="color: #66cc66;">&#40;</span>U0LSR &amp; 0x20<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp; &nbsp; U0THR = CR; <span style="color: #808080; font-style: italic;">/* output CR */</span><br />&nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>!<span style="color: #66cc66;">&#40;</span>U0LSR &amp; 0x20<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span>U0THR = ch<span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #66cc66;">&#125;</span><br /><span style="color: #993333;">int</span> getchar <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">void</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">/* Read character from Serial Port */</span><br /><span style="color: #66cc66;">&#123;</span><br /><span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>!<span style="color: #66cc66;">&#40;</span>U0LSR &amp; 0x01<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #b1b100;">return</span> <span style="color: #66cc66;">&#40;</span>U0RBR<span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #66cc66;">&#125;</span></div></div><br /><br />we will next discuss the above code!! till then bye  <img src='http://www.8051projects.net/e107_images/emotes/yahoo/103.gif' alt='' style='vertical-align:middle; border:0' />  <br /><br /><br />for users referring to user manual for lpc214x series please note:<br />PLL in all above  discussion shall be veiwed as PLL0  similarly all registers will change<br />ex <br />PLLCFG =>PLL0CFG<br />PLLCON =>PLL0CON<br />the second PLL will be discussed under the topic USB!! till then no mention of PLL1 registers <img src='http://www.8051projects.net/e107_images/emotes/yahoo/4.gif' alt='' style='vertical-align:middle; border:0' /> <br />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. <br /><br /><br /><br /><span style='font-size:14px'><strong class='bbcode bold'><em class='bbcode italic'>please  post your doubts (UART) here....<br /></em><br /><a class='bbcode' href='http://www.8051projects.net/forum-t4322-last.html' rel='external'  target='_blank'>http://www.8051projects.net/forum-t4322-last.html</a></strong></span>]]></description>
<author>shyam&lt;shyam@nospam.com&gt;</author>
<pubDate>Fri, 28 Dec 2007 13:46:42 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t4311.html</guid>
</item>
				</channel>
				</rss>