<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Volts and Bytes<title>&#187; I/O Port</title>
</title>
	<atom:link href="http://voltsandbytes.com/tag/io-port/feed/" rel="self" type="application/rss+xml" />
	<link>http://voltsandbytes.com</link>
	<description>Microcontroller projects, tutorials, and other electronics stuffs...</description>
	<lastBuildDate>Tue, 31 Aug 2010 09:57:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>8051 Tutorial 3: I/O Port Programming in C</title>
		<link>http://voltsandbytes.com/8051-tutorial-3-io-port-programming-in-c/</link>
		<comments>http://voltsandbytes.com/8051-tutorial-3-io-port-programming-in-c/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 00:53:22 +0000</pubDate>
		<dc:creator>jer</dc:creator>
				<category><![CDATA[8051 Microcontroller]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[8051]]></category>
		<category><![CDATA[AT89C2051]]></category>
		<category><![CDATA[I/O Port]]></category>
		<category><![CDATA[Microcontroller]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://voltsandbytes.com/?p=315</guid>
		<description><![CDATA[This tutorial will introduce you the basics about programming the input and output ports on an 8051 microcontroller using C language. Therefore, it is recommended that the reader is familiar or has basic knowledge about C programming language and electronics circuit analysis. I am going to use Atmel‘s AT89C2051 as an example for the 8051 [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial will introduce you the basics about programming the input and output ports on an 8051 microcontroller using C language. Therefore, it is recommended that the reader is familiar or has basic knowledge about C programming language and electronics circuit analysis. I am going to use <a href="http://www.atmel.com/">Atmel</a>‘s <a href="http://www.atmel.com/dyn/products/product_card.asp?part_id=1938">AT89C2051</a> as an example for the 8051 microcontroller and the C compiler that I am going to use is the RC-51 which is included with the <a href="http://www.mcu-raisonance.com/~free-evaluation-8051-software-toolset__microcontrollers__product~product__T017:4d4ua0vi1fsg.html">Free Evaluation 8051 Software Toolset</a> of <a href="http://www.mcu-raisonance.com/">Raisonance</a>. You may see <a href="http://www.mcu-raisonance.com/~free-evaluation-8051-software-toolset__microcontrollers__product~product__T017:4d4ua0vi1fsg.html">this</a> for more info about the toolset or you may download the free evaluation 8051 Software Toolset  <a href="http://www.mcu-raisonance.com/mcu_downloads.html/">here</a>(RKit-Eval51). See <a href="http://voltsandbytes.com/8051-tutorial-2-raisonances-free-evaluation-8051-software-toolset/">this tutorial</a> for a quick start guide with this software.</p>
<p>For an introduction about AT89C2051, see <a href="http://voltsandbytes.com/8051-tutorial-1-introduction-to-at89c2051/">this</a>.</p>
<p><strong>AT89C2051 General Input and Output Ports</strong></p>
<p>The original 8051 microcontroller (40 pins)  contains 4 digital input and output ports which are <strong>P0</strong>, <strong>P1</strong>, <strong>P2</strong>, and <strong>P3</strong>. Its little brother, AT89C2051 (20pins), only contains two bidirectional input and output ports which are <strong>P1</strong> and <strong>P3</strong>. Both ports are one-byte (8-bits) wide and each pin of each port can be accessed externally (see the pin diagram below) except <strong>bit 6 of P3 </strong>or <strong>P3.6</strong>.<img class="aligncenter size-full wp-image-107" title="AT89C2051-pin" src="http://voltsandbytes.com/wp-content/uploads/2010/07/AT89C2051-pin.jpg" alt="" width="600" height="389" /></p>
<p><strong><span id="more-315"></span>P3.6</strong>, however, do exist. It is hardwired internally to the output of AT89C2051′s on-chip analog comparator (see diagram below). All port pins of AT89C2051 have internal pullups except <strong>P1.0</strong> and <strong>P1.1. </strong>Pins <strong>P1.0 and P1.1</strong> do not have internal pullups because these pins are also used as inputs of the on-chip analog comparator.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-115" title="AT89C2051- p1p3" src="http://voltsandbytes.com/wp-content/uploads/2010/07/AT89C2051-p1p3.png" alt="" width="600" height="236" /></p>
<p style="text-align: center;"><script type="text/javascript"><!--
google_ad_client = "pub-4129695434726741";
google_ad_slot = "5940435964";
google_ad_width = 468;
google_ad_height = 15;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
</p>
<p>As you can see, the pins of AT89C2051 has alternate functions and we will discuss those functions in the next series of tutorials about AT89C2051. Just for a quick view of these alternate functions, please look at the table below.</p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="69" valign="top"><strong>Port Pin</strong></td>
<td width="459" valign="top"><strong>Alternate Functions</strong></td>
</tr>
<tr>
<td width="69" valign="top">P1.0</td>
<td width="459" valign="top">AIN0 (positive input) of the on-chip precision analog comparator</td>
</tr>
<tr>
<td width="69" valign="top">P1.1</td>
<td width="459" valign="top">AIN1 (negative input) of the on-chip precision analog comparator</td>
</tr>
<tr>
<td width="69" valign="top">P3.0</td>
<td width="459" valign="top">RXD (serial input port)</td>
</tr>
<tr>
<td width="69" valign="top">P3.1</td>
<td width="459" valign="top">TXD (serial output port)</td>
</tr>
<tr>
<td width="69" valign="top">P3.2</td>
<td width="459" valign="top">INT0 (external interrupt 0)</td>
</tr>
<tr>
<td width="69" valign="top">P3.3</td>
<td width="459" valign="top">INT1 (external interrupt 1)</td>
</tr>
<tr>
<td width="69" valign="top">P3.4</td>
<td width="459" valign="top">T0 (timer 0 external input)</td>
</tr>
<tr>
<td width="69" valign="top">P3.5</td>
<td width="459" valign="top">T1 (timer 1 external input)</td>
</tr>
</tbody>
</table>
<p style="text-align: center;">
]]></content:encoded>
			<wfw:commentRss>http://voltsandbytes.com/8051-tutorial-3-io-port-programming-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
