http://www.8051projects.net/mediawiki/index.php?title=8051_UART/Serial_Communication_Tutorial&feed=atom&action=history
8051 UART/Serial Communication Tutorial - Revision history
2024-03-29T10:55:17Z
Revision history for this page on the wiki
MediaWiki 1.28.0
http://www.8051projects.net/mediawiki/index.php?title=8051_UART/Serial_Communication_Tutorial&diff=158&oldid=prev
Ajay Bhargav: /* Help & Queries */
2015-03-03T14:38:54Z
<p><span dir="auto"><span class="autocomment">Help & Queries</span></span></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 14:38, 3 March 2015</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l86" >Line 86:</td>
<td colspan="2" class="diff-lineno">Line 86:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[Category:8051 Tutorials]]</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[Category:8051 Tutorials]]</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Serial Port Peripherals]]</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Serial Port Peripherals]]</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>{{#set:<ins class="diffchange diffchange-inline">has type:</ins>tutorial<ins class="diffchange diffchange-inline">}}{{#set</ins>:<ins class="diffchange diffchange-inline">tutorial of</ins>:8051 <ins class="diffchange diffchange-inline">microcontroller</ins>}}</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>{{#set:<del class="diffchange diffchange-inline">is </del>tutorial <del class="diffchange diffchange-inline">for</del>::8051 <del class="diffchange diffchange-inline">Microcontroller</del>}}</div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>{{#set:has category::8051 Tutorials}}</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>{{#set:has category::8051 Tutorials}}</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>{{#set:has category::Serial Port Peripherals}}</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>{{#set:has category::Serial Port Peripherals}}</div></td></tr>
</table>
Ajay Bhargav
http://www.8051projects.net/mediawiki/index.php?title=8051_UART/Serial_Communication_Tutorial&diff=157&oldid=prev
Ajay Bhargav: /* Help & Queries */
2015-03-03T14:22:05Z
<p><span dir="auto"><span class="autocomment">Help & Queries</span></span></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 14:22, 3 March 2015</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l84" >Line 84:</td>
<td colspan="2" class="diff-lineno">Line 84:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>If you have any queries, doubts or feedback on this tutorial please share in our [http://www.8051projects.net/forum.html discussion forum].</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>If you have any queries, doubts or feedback on this tutorial please share in our [http://www.8051projects.net/forum.html discussion forum].</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Tutorials]]</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>[[Category:<ins class="diffchange diffchange-inline">8051 </ins>Tutorials]]</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Serial Port Peripherals]]</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Serial Port Peripherals]]</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">{{#set:is tutorial for::8051 Microcontroller}}</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">{{#set:has category::8051 Tutorials}}</ins></div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">{{#set:has category::Serial Port Peripherals}}</ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>{{#seo:</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>{{#seo:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>|title=8051 Uart/Serial Communication Tutorial</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>|title=8051 Uart/Serial Communication Tutorial</div></td></tr>
</table>
Ajay Bhargav
http://www.8051projects.net/mediawiki/index.php?title=8051_UART/Serial_Communication_Tutorial&diff=132&oldid=prev
Ajay Bhargav: Initial commit 8051 serial
2015-02-25T11:12:48Z
<p>Initial commit 8051 serial</p>
<p><b>New page</b></p><div>In 8051, we make use of Timer 1 to generate the required baud rate. Following are the registers that are need to be configured to communicate over UART.<br />
<br />
*TMOD<br />
*SCON<br />
*TH1<br />
*TL1<br />
*TCON<br />
<br />
'''TMOD:''' This register is used to set the mode of Timer0 and Timer1. It is also used to select whether the timers are used as Timer or Counter.<br />
<br />
'''SCON:''' Serial Control register has various functions like.. it has flags for Framing error, Transmit interrupt and receive interrupt. Its used to select the serial port mode, to enable or disable the reception etc.<br />
<br />
'''TCON:''' This register has various flag and control bits e.g. Timer overflow flags, interrupt edge flags, timer control bits to start/stop the timer.<br />
<br />
'''TH1 & TL1:''' Timer registers for Timer 1 determines the baudrate of UART.<br />
<br />
More information on the above registers can be found in the 8051 Hardware manual.<br />
<br />
==== Initializing UART in 8051 ====<br />
In Assembly:<br />
<source lang="asm">Serial_Init:<br />
;Set timer 1 mode to 8-bit Auto-Reload<br />
mov TMOD,#20H<br />
;Enable reception<br />
;Set Serial port mode to 8-bit UART<br />
mov SCON,#50H<br />
;Set baudrate to 9600 at 11.0592MHz<br />
mov TH1,#0FDH<br />
mov TL1,#0FDH<br />
;Start Timer<br />
setb TR1<br />
ret<br />
</source><br />
in C we can do this as...<br />
<source lang="c">#include <reg51.h>.<br />
void serial_init(){<br />
TMOD = 0x20;<br />
SCON = 0x50;<br />
TH1 = 0xFD;<br />
TL1 = 0xFD;<br />
TR1 = 1;<br />
}<br />
</source><br />
To Send data to the serial port we just have to move the data in SBUF (serial buffer register) and wait for the Transmit Interrupt flag to be set. While receiving we wait for the Receive interrupt flag to be set and read the data from SBUF register. This can be done as shown below...<br />
<source lang="asm">Serial_Send:<br />
;wait for last data to be<br />
;sent completely<br />
jnb TI,Serial_Send<br />
;clear the transmit interrupt flag<br />
clr TI<br />
;Then move the data to send in SBUF<br />
mov SBUF,A<br />
ret<br />
<br />
Serial_Read:<br />
;Wait for Receive interrupt flag<br />
jnb RI,Serial_Read<br />
;If flag is set then clear it<br />
clr RI<br />
;Then read data from SBUF<br />
mov A,SBUF<br />
ret<br />
</source><br />
Similarly in C we can write functions for read and write on serial port.<br />
<source lang="c">void serial_send(unsigned char dat){<br />
while(!TI);<br />
TI = 0;<br />
SBUF = dat;<br />
}<br />
unsigned char serial_read(){<br />
while(!RI);<br />
RI = 0;<br />
return SBUF;<br />
}<br />
</source><br />
== See Also ==<br />
* [[UART Communication Tutorial]] - Basics of UART<br />
* [[8051 Software UART Tutorial]]<br />
* [[AVR UART/Serial Communication Tutorial]]<br />
* [[GPS Receiver Interfacing over UART Tutorial]]<br />
* [[GSM Modem Interfacing over UART Tutorial]]<br />
<br />
== Help & Queries ==<br />
If you have any queries, doubts or feedback on this tutorial please share in our [http://www.8051projects.net/forum.html discussion forum].<br />
<br />
[[Category:Tutorials]]<br />
[[Category:Serial Port Peripherals]]<br />
<br />
{{#seo:<br />
|title=8051 Uart/Serial Communication Tutorial<br />
|keywords=Serial Communication, UART, USART, MAX232 intefacing, MAX232 with microcontroller, 8051 communication, AVR serial communication<br />
|description=Serial communication using UART or USART of a microcontroller 8051 AVR PIC, software implementation of half-duplex UART and MAX232 interfacing with microcontrollers 8051 AVR PIC.<br />
}}</div>
Ajay Bhargav