<?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; 8051 Microcontroller</title>
</title>
	<atom:link href="http://voltsandbytes.com/category/tutorials/8051-microcontroller/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 6: 8051 Interrupts Programming in C</title>
		<link>http://voltsandbytes.com/8051-tutorial-6-8051-interrupts-programming-in-c/</link>
		<comments>http://voltsandbytes.com/8051-tutorial-6-8051-interrupts-programming-in-c/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 04:35: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[Interrupt]]></category>
		<category><![CDATA[Interrupts]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://voltsandbytes.com/?p=360</guid>
		<description><![CDATA[What is an interrupt? An interrupt is an asynchronous signal that needs attention. An interrupt stops the CPU of a microcontroller, leaving the tasks that it is currently doing, to give attention to the interrupt signal. Once the attention has been given to the interrupt signal, the CPU goes back to its unaccomplished task before the interrupt [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;"><strong>What is an interrupt?</strong></p>
<p>An interrupt is an asynchronous signal that needs attention. An interrupt stops the CPU of a microcontroller, leaving the tasks that it is currently doing, to give attention to the interrupt signal. Once the attention has been given to the interrupt signal, the CPU goes back to its unaccomplished task before the interrupt has occured and continues the task.</p>
<p><strong>The Interrupts of AT89C2051</strong></p>
<p>The interrupts of AT89C2051 is compatible with the interrupts of the original 8051 microcontroller. It has 6 interrupts sources ( 5 interrupts + RESET). The interrupt sources of AT89C2051 are the following:</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="19" valign="top"> </td>
<td width="138" valign="top"><strong>Interrupt </strong></td>
<td width="90" valign="top"><strong>Source</strong></td>
<td width="132" valign="top"><strong>Priority Number</strong></td>
</tr>
<tr>
<td width="19" valign="top">1</td>
<td width="138" valign="top">RESET</td>
<td width="90" valign="top">RST</td>
<td width="132" valign="top">N/A</td>
</tr>
<tr>
<td width="19" valign="top">2</td>
<td width="138" valign="top">External Interrupt 0</td>
<td width="90" valign="top">IE0</td>
<td width="132" valign="top">0</td>
</tr>
<tr>
<td width="19" valign="top">3</td>
<td width="138" valign="top">Timer 0 Interrupt</td>
<td width="90" valign="top">TF0</td>
<td width="132" valign="top">1</td>
</tr>
<tr>
<td width="19" valign="top">4</td>
<td width="138" valign="top">External Interrupt 1</td>
<td width="90" valign="top">IE1</td>
<td width="132" valign="top">2</td>
</tr>
<tr>
<td width="19" valign="top">5</td>
<td width="138" valign="top">Timer 1 Interrupt</td>
<td width="90" valign="top">TF1</td>
<td width="132" valign="top">3</td>
</tr>
<tr>
<td width="19" valign="top">6</td>
<td width="138" valign="top">UART Interrupt</td>
<td width="90" valign="top">RI or TI</td>
<td width="132" valign="top">4</td>
</tr>
</tbody>
</table>
<p><em>Please note that in this tutorial, we will not consider the interrupt from RESET.</em></p>
<p>The table above shows the interrupt sources of AT89C2051 and their respective interrupt priority number. Knowing the priority number is important specially if two different interrupt sources occur at the same time.<span id="more-360"></span></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><strong>Interrupt Enable Register</strong></p>
<p>The <strong>Interrupt Enable</strong> (<strong>IE</strong>) register is responsible in enabling and disabling the different interrupt sources of 8051.</p>
<p style="text-align: center;"><img class="size-full wp-image-361  aligncenter" title="IEregister" src="http://voltsandbytes.com/wp-content/uploads/2010/08/IEregister.jpg" alt="" width="588" height="90" /></p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="43" valign="top"><strong>EA</strong></td>
<td width="595" valign="top">Disables all interrupts. If EA = 0, no interrupt is acknowledged. If EA = 1, each interrupt source is individually enabled or disabled by setting or clearing its enable bit.</td>
</tr>
<tr>
<td width="43" valign="top"><strong>__</strong></td>
<td width="595" valign="top">Not implemented</td>
</tr>
<tr>
<td width="43" valign="top"><strong>__</strong></td>
<td width="595" valign="top">Not implemented in AT89C2051 but it is implemented as ET2 in 8052 compatible microcontrollers such as AT89S52 (Enables or disables the Timer 2 overflow or capture interrupt)</td>
</tr>
<tr>
<td width="43" valign="top"><strong>ES</strong></td>
<td width="595" valign="top">Enables or disables the serial port interrupt.</td>
</tr>
<tr>
<td width="43" valign="top"><strong>ET1</strong></td>
<td width="595" valign="top">Enables or disables the Timer 1 overflow interrupt.</td>
</tr>
<tr>
<td width="43" valign="top"><strong>EX1</strong></td>
<td width="595" valign="top">Enables or disables External Interrupt 1.</td>
</tr>
<tr>
<td width="43" valign="top"><strong>ET0</strong></td>
<td width="595" valign="top">Enables or disables the Timer 0 overflow interrupt.</td>
</tr>
<tr>
<td width="43" valign="top"><strong>EX0</strong></td>
<td width="595" valign="top">Enables or disables External Interrupt 0.</td>
</tr>
</tbody>
</table>
<p style="text-align: center;"><strong></strong> <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><strong>How To Enable an Interrupt</strong></p>
<p>1. Initialize the sources of interrupts such as Timers, External Interrupts, or UART.</p>
<p>2. Set the bits of the<strong> IE</strong> register that corresponds to the interrupt sources that you want to be enabled.</p>
<p>Example: If you want to enable the interrupt of the serial port or UART set<strong> ES</strong> to 1 or <strong>ES</strong>=1.</p>
<p>3. Enable the global interrupt by setting the <strong>EA</strong> bit of the <strong>IE</strong> register (EA=1).</p>
<p style="text-align: center;"><strong></strong> <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><strong>How to Write an interrupt service routine or ISR</strong></p>
<p>The <strong>interrupt service routine</strong> or<strong> ISR</strong> is the routine that an MCU is servicing every time an interrupt occurs. It can be treated as an ordinary subroutine in a C program.</p>
<p>The format of the <strong>ISR</strong> is:</p>
<blockquote><p>void <strong><em>your_ISR_name</em></strong>(void) interrupt <strong><em>interrupt_priority_number</em></strong><br />
{<br />
  <strong>//your routine here</strong><br />
}</p></blockquote>
<p>The <em>your_ISR_name</em> is user defined. It can be any name.</p>
<p>The <em>interrupt_priority_number</em> is fixed depending on the source of the interrupt. Refer to the table of the interrupt sources above for reference.</p>
]]></content:encoded>
			<wfw:commentRss>http://voltsandbytes.com/8051-tutorial-6-8051-interrupts-programming-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>8051 Tutorial 5: 8051 UART Programming in C</title>
		<link>http://voltsandbytes.com/8051-tutorial-5-8051-uart-programming-in-c/</link>
		<comments>http://voltsandbytes.com/8051-tutorial-5-8051-uart-programming-in-c/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 02:49:08 +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[RS-232]]></category>
		<category><![CDATA[RS232]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[UART]]></category>

		<guid isPermaLink="false">http://voltsandbytes.com/?p=344</guid>
		<description><![CDATA[What is UART? UART stands for Universal Asynchronous Receiver/Transmitter. As its name implies, it is universal. It can be used to establish a communication between a microcontroller and another device – microcontroller, USB controller, Bluetooth modules, GSM modules, GPS modules, personal computers, etc. I am not going to discuss the UART protocol here. If UART [...]]]></description>
			<content:encoded><![CDATA[<p><strong>What is UART?</strong></p>
<p><strong>UART</strong> stands for <strong>Universal Asynchronous Receiver/Transmitter</strong>. As its name implies, it is universal. It can be used to establish a communication between a microcontroller and another device – microcontroller, USB controller, Bluetooth modules, GSM modules, GPS modules, personal computers, etc.</p>
<p>I am not going to discuss the UART protocol here. If UART is still unknown to you, you may read <a href="http://en.wikipedia.org/wiki/UART">this article from wikipedia</a> first.</p>
<p><strong>What is RS-232?</strong></p>
<p><strong>RS-232</strong> is a standard for serial transmission of data between a <strong>DTE</strong> (Data Terminal Equipment) and a <strong>DCE</strong> (Data Circuit-terminating Equipment). It is commonly found in desktop computers where it is commonly referred as <strong>COM port</strong>. You can read <a href="http://en.wikipedia.org/wiki/RS-232">this wikipedia article</a> for more info about the RS-232 standard.</p>
<p><strong>AT89C2051 UART</strong></p>
<p style="text-align: left;">The AT89C2051 has one UART port. Its <strong>TXD</strong> (<em>Transmit</em>) pin is the same as its <strong>P3.1</strong> pin. Its <strong>RXD</strong> (<em>Receive</em>) pin is the same as its <strong>P3.0 </strong>pin.<span id="more-344"></span></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><strong>AT89C2051 RS-232 Interface</strong></p>
<p>The UART port of a microcontroller can be used to interface to a RS-232 port of a personal computer. However, the voltage levels of UART must be converted to voltage levels compatible to RS-232.</p>
<p>To convert UART voltage levels to RS-232 voltage levels, you may use the following circuits:</p>
<p><strong>1. Using a MAX232 or similar IC</strong></p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-349" title="ttl-rs232-max232" src="http://voltsandbytes.com/wp-content/uploads/2010/08/ttl-rs232-max232.jpg" alt="" width="588" height="392" /></p>
<p>This is the most preferred circuit to convert UART using the TTL voltage levels to RS232 voltage levels. The 5V levels are converted by MAX232 to -9V to -12V and vice versa. The 0V levels are converted by MAX232 to +9V to +12V and vice versa.</p>
<p>The female DB-9 connector is used to connect with the RS-232 port of a personal computer.</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> </p>
<p><strong>2. Using Transistors</strong></p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-350" title="ttl-rs232-transistor" src="http://voltsandbytes.com/wp-content/uploads/2010/08/ttl-rs232-transistor.jpg" alt="" width="588" height="405" /></p>
<p style="text-align: left;">
]]></content:encoded>
			<wfw:commentRss>http://voltsandbytes.com/8051-tutorial-5-8051-uart-programming-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>8051 Tutorial 4: 8051 Timer/Counter Programming in C</title>
		<link>http://voltsandbytes.com/8051-tutorial-4-8051-timercounter-programming-in-c/</link>
		<comments>http://voltsandbytes.com/8051-tutorial-4-8051-timercounter-programming-in-c/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 02:26:24 +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[Counter]]></category>
		<category><![CDATA[Microcontroller]]></category>
		<category><![CDATA[Timer]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://voltsandbytes.com/?p=326</guid>
		<description><![CDATA[This tutorial is about using the internal timers/counters of 8051. This will tackle the registers associated with the internal timers/counters of 8051 and this will also enumerate the steps on using the timers/counters. The Timers/Counters of AT89C2051 The AT89C2051 has two 16-bit Timer/Counters: Timer0 and Timer1. This means that it can time/count from 0-65535 (2^16-1). The [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial is about using the internal timers/counters of 8051. This will tackle the registers associated with the internal timers/counters of 8051 and this will also enumerate the steps on using the timers/counters.</p>
<p><strong>The Timers/Counters of AT89C2051</strong></p>
<p>The AT89C2051 has two <strong>16-bit</strong> Timer/Counters: <strong>Timer0</strong> and <strong>Timer1</strong>. This means that it can time/count from <strong>0-65535</strong> (2^16-1). The timers can be used to generate accurate delays and the counters can be used to count events. An event can be anything. It can be a pulse, a push, a pull, or any stimulus.<span id="more-326"></span></p>
<p><strong>Basic Registers of Timer/Counter</strong></p>
<p>1. Timer0 Registers</p>
<p>Timer0 is a 16-bit timer/counter and it is accesed as <strong>TH0</strong> (Timer0 high byte) and <strong>TL0</strong> (Timer0 low byte).</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-329" title="Timer0" src="http://voltsandbytes.com/wp-content/uploads/2010/08/Timer0.jpg" alt="" width="588" height="51" /></p>
<p>2. Timer1 Registers</p>
<p>Timer1 is a 16-bit timer/counter and it is accesed as <strong>TH1</strong> (Timer1 high byte) and <strong>TL1</strong> (Timer1 low byte).</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-330" title="Timer1" src="http://voltsandbytes.com/wp-content/uploads/2010/08/Timer1.jpg" alt="" width="588" height="51" /></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>3. TMOD Register</p>
<p>The TMOD (timer mode) register sets the operational modes of Time0 and Timer1. It is 8 bits wide in which the upper nibble is for Timer1 and the lower nibble is for Timer0.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-331" title="TMOD" src="http://voltsandbytes.com/wp-content/uploads/2010/08/TMOD.jpg" alt="" width="588" height="112" /></p>
<p><strong>GATE</strong>: Gating control when set. Timer/Counter x is enabled only while INTx pin is high and TRx control pin is set. When cleared, Timer x is enabled whenever TRx control bit is set.</p>
<p><strong>C/T</strong>: If <strong>C/T</strong> = 1, the counter operation is selected. If <strong>C/T</strong>=0, the timer operation is selected</p>
<p><strong>M1</strong>: Mode bit 1</p>
<p><strong>M0</strong>: Mode bit 0</p>
<p><em>When the timer operating mode is selected, the clock source of the timer is the same as the clock source of AT89C2051 (ex: external quartz crystal). The frequency of the timer’s clock source is equal to the frequency of At89C2051′s</em><em> clock source divided by 12. If the clock source is a 12MHz quartz crystal, the timer’s clock frequency is equal to 12MHz/12  = 1MHz.</em></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>4. TCON Register</p>
<p>The TCON (Timer/counter control) register is responsible to the control and status bits of  AT89C2051′s timers/counters (and external interrupts).</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-328" title="TCON" src="http://voltsandbytes.com/wp-content/uploads/2010/08/TCON.jpg" alt="" width="588" height="87" /></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>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="44"><strong>TF1</strong></td>
<td width="583" valign="top">Timer 1 overflow flag. Set by hardware on Timer/Counter overflow. Cleared by hardware when processor vectors to interrupt routine.</td>
</tr>
<tr>
<td width="44"><strong>TR1</strong></td>
<td width="583" valign="top">Timer 1 run control bit. Set/cleared by software to turn Timer/Counter on/off.</td>
</tr>
<tr>
<td width="44"><strong>TF0</strong></td>
<td width="583" valign="top">Timer 0 overflow flag. Set by hardware on Timer/Counter overflow. Cleared by hardware when processor vectors to interrupt routine.</td>
</tr>
<tr>
<td width="44"><strong>TR0</strong></td>
<td width="583" valign="top">Timer 0 run control bit. Set/cleared by software to turn Timer/Counter on/off.</td>
</tr>
<tr>
<td width="44"><strong>IE1</strong></td>
<td width="583" valign="top">Interrupt 1 edge flag. Set by hardware when external interrupt edge detected. Cleared when interrupt processed.</td>
</tr>
<tr>
<td width="44"><strong>IT1</strong></td>
<td width="583" valign="top">Interrupt 1 type control bit. Set/cleared by software to specify falling edge/low level triggered external interrupts.</td>
</tr>
<tr>
<td width="44"><strong>IE0</strong></td>
<td width="583" valign="top">Interrupt 0 edge flag. Set by hardware when external interrupt edge detected. Cleared when interrupt processed.</td>
</tr>
<tr>
<td width="44"><strong>IT0</strong></td>
<td width="583" valign="top">Interrupt 0 type control bit. Set/cleared by software to specify falling edge/low level triggered external interrupts.</td>
</tr>
</tbody>
</table>
<p style="text-align: center;">
]]></content:encoded>
			<wfw:commentRss>http://voltsandbytes.com/8051-tutorial-4-8051-timercounter-programming-in-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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>
		<item>
		<title>8051 Tutorial 2: Raisonance&#8217;s Free Evaluation 8051 Software Toolset</title>
		<link>http://voltsandbytes.com/8051-tutorial-2-raisonances-free-evaluation-8051-software-toolset/</link>
		<comments>http://voltsandbytes.com/8051-tutorial-2-raisonances-free-evaluation-8051-software-toolset/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 05:20:10 +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[Microcontroller]]></category>
		<category><![CDATA[Raisonance]]></category>
		<category><![CDATA[RC-51]]></category>
		<category><![CDATA[Ride]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://voltsandbytes.com/?p=293</guid>
		<description><![CDATA[In this tutorial, I am going to discuss how to create a C project intended for 8051 family of microcontrollers. I am going to use the free evaluation toolkit for 8051 from Raisonance. This tutorial aims to discuss the basics of creating project using the toolkit from Raisonance. However, the reader is advised to read [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial, I am going to discuss how to create a C project intended for 8051 family of microcontrollers. I am going to use the free evaluation toolkit for 8051 from <a href="http://www.mcu-raisonance.com/">Raisonance</a>. This tutorial aims to discuss the basics of creating project using the toolkit from <a href="http://www.mcu-raisonance.com/">Raisonance</a>. However, the reader is advised to read the documentation of the said toolkit for more advanced usage and configuration.</p>
<p><strong>What is the Free Evaluation 8051 Software Toolset of Raisonance?</strong></p>
<p>The <a href="http://www.mcu-raisonance.com/~free-evaluation-8051-software-toolset__microcontrollers__product~product__T017:4d4ua0vi1fsg.html">Free Evaluation 8051 Software Toolset of Raisonance</a> is a free development tool provided by Raisonance that enables developers to compile and debug applications using 8051 microcontrollers. This toolset includes the following:</p>
<ul>
<li>
<div style="padding-left: 30px;"><strong>Ride6</strong> integrated development environment</div>
</li>
<li>
<div style="padding-left: 30px;"><strong>RC-51</strong> ANSI C compiler, output up to 4Kbytes of code</div>
</li>
<li>
<div style="padding-left: 30px;"><strong>MA-51</strong> Macro Assembler, output up to 4Kbytes of code</div>
</li>
<li>
<div style="padding-left: 30px;"><strong>LX-51</strong> Code Banking Linker, output up to 4Kbytes of code</div>
</li>
<li>
<div style="padding-left: 30px;"><strong>KR-51Tiny</strong> RTOS, supports up to 3 tasks</div>
</li>
<li>
<div style="padding-left: 30px;"><strong>SIMICE-51</strong> Simulator, debug up to 4Kbytes of code</div>
</li>
</ul>
<p>For more info about this toolset, you may visit <a href="http://www.mcu-raisonance.com/~free-evaluation-8051-software-toolset__microcontrollers__product~product__T017:4d4ua0vi1fsg.html">this</a>. You may also download the toolset (look for RKit-Eval51) <a href="http://www.mcu-raisonance.com/mcu_downloads.html">here</a>.<span id="more-293"></span></p>
<p><strong>Creating a Project using the Free Evaluation 8051 Software Toolset</strong></p>
<p>1. The first thing that you need to do is to download and install the Free Evaluation 8051 Software Toolset of Raisonance. Installation should be easy and straight forward. After you have installed the application, you are now ready to create your first target application using the software toolset. In this tutorial, our target device would be <a href="http://www.atmel.com/dyn/Products/Product_card.asp?part_id=1938">AT89C2051</a> of <a href="http://www.atmel.com/">Atmel</a>.</p>
<p>2. Next, start the <strong>RIDE6 IDE</strong>. You may go to <strong>Start-&gt;Programs-&gt;Raisonance Kit 6.1</strong> and click the <strong>Ride IDE</strong> icon.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-294" title="ride1" src="http://voltsandbytes.com/wp-content/uploads/2010/08/ride1.jpg" alt="" width="588" height="365" /></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>3. The Ride integrated development environment should start. Once the IDE has started, you should see something like this:</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-295" title="ride2" src="http://voltsandbytes.com/wp-content/uploads/2010/08/ride2.jpg" alt="" width="588" height="353" /></p>
<p>4. Locate the menu bar and point your mouse to the <strong>Project</strong> menu. Under the <strong>Project</strong> menu, click <strong>New</strong>…</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-296" title="ride3" src="http://voltsandbytes.com/wp-content/uploads/2010/08/ride3.jpg" alt="" width="540" height="382" /></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>5. A <strong>Project</strong> dialog box will appear. Type your desired project name under the <strong>Application Name</strong> box. Locate where you want to save your project under the <strong>Directory</strong> field. The <strong>Target Family</strong> must be <strong>80C51</strong>. Under <strong>Type of application</strong> field, choose <strong>Application</strong>. Click <strong>Next</strong>.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-297" title="ride4" src="http://voltsandbytes.com/wp-content/uploads/2010/08/ride4.jpg" alt="" width="588" height="390" /></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>
]]></content:encoded>
			<wfw:commentRss>http://voltsandbytes.com/8051-tutorial-2-raisonances-free-evaluation-8051-software-toolset/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>8051 Tutorial 1: Introduction to AT89C2051</title>
		<link>http://voltsandbytes.com/8051-tutorial-1-introduction-to-at89c2051/</link>
		<comments>http://voltsandbytes.com/8051-tutorial-1-introduction-to-at89c2051/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 04:51:06 +0000</pubDate>
		<dc:creator>jer</dc:creator>
				<category><![CDATA[8051 Microcontroller]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[8051]]></category>
		<category><![CDATA[AT89C2051]]></category>
		<category><![CDATA[Microcontroller]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://voltsandbytes.com/?p=101</guid>
		<description><![CDATA[What is 8051? The 8051 is a popular 8-bit single chip microcontroller which was first introduced by Intel. The first 8051 is a 40-pin microcontroller which has 4kB of program memory, 128 bytes of RAM, 2 timer/counter, 1 UART, and six interrupt sources. Later on, the 8052 microcontroller was introduced. The 8052 microcontroller is a better [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;"><strong>What is 8051?</strong></p>
<p>The 8051 is a popular 8-bit single chip <a href="http://en.wikipedia.org/wiki/Microcontroller">microcontroller</a> which was first introduced by <a href="http://www.intel.com/">Intel</a>. The <a href="http://en.wikipedia.org/wiki/Intel_8051">first 8051</a> is a 40-pin microcontroller which has 4kB of program memory, 128 bytes of RAM, 2 timer/counter, 1 UART, and six interrupt sources.</p>
<p>Later on, the 8052 microcontroller was introduced. The 8052 microcontroller is a better version of 8051 microcontroller. It has 8kB of code memory and 256 bytes of RAM. It also has an additional timer.</p>
<p>8051 became very propular and it became an industry standard. Due to its popularity, many semiconductor manufacturers like <a href="http://www.atmel.com/">Atmel</a>, <a href="http://www.infineon.com/">Infineon Technologies</a>, <a href="http://www.maxim-ic.com/">Maxim Integrated Products</a>, <a href="http://www.nxp.com/">NXP</a>, <a href="http://www.st.com/">ST Microelectronics</a>, <a href="https://www.silabs.com/">Silicon Laboratories</a>, <a href="http://www.ti.com/">Texas Instruments</a>, <a href="http://www.cypress.com/">Cypress Semiconductor</a>, etc have included 8051 in their line of products.<span id="more-101"></span></p>
<p><strong>What is AT89C2051?</strong></p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-128" title="AT89C2051" src="http://voltsandbytes.com/wp-content/uploads/2010/07/AT89C2051.jpg" alt="" width="600" height="402" /></p>
<p><a href="http://www.atmel.com/dyn/products/product_card.asp?part_id=1938">AT89C2051</a> is manufactured by Atmel and it is a member of 8051 family of microcontrollers. Unlike the original 8051 microcontroller which has 40 pins, AT89C2051 has only 20 pins which makes it ideal for 8051 beginners. It takes the standard features of the original features of 8051 except that it has only 20 pins compared to 40 pins of the original 8051. However, AT89C2051 is made of flash program memory and it has additional on-chip analog comparator.</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="213" valign="top"><strong>8051</strong></td>
<td width="213" valign="top"><strong>8052</strong></td>
<td width="213" valign="top"><strong>AT89C2051</strong></td>
</tr>
<tr>
<td width="213" valign="top">4kB code memory</td>
<td width="213" valign="top">8kB code memory</td>
<td width="213" valign="top">2 kB code memory</td>
</tr>
<tr>
<td width="213" valign="top">128 bytes RAM</td>
<td width="213" valign="top">256 bytes RAM</td>
<td width="213" valign="top">128 bytes RAM</td>
</tr>
<tr>
<td width="213" valign="top">Two 16-bit Timer Counters</td>
<td width="213" valign="top">Three 16-bit Timer/Counters</td>
<td width="213" valign="top">Two 16-bit Timer Counters</td>
</tr>
<tr>
<td width="213" valign="top">One Programmable Serial UART</td>
<td width="213" valign="top">One Programmable Serial UART</td>
<td width="213" valign="top">One Programmable Serial UART</td>
</tr>
<tr>
<td width="213" valign="top">40 pins (32 IO pins)</td>
<td width="213" valign="top">40 pins (32 IO pins)</td>
<td width="213" valign="top">20 pins (15 IO pins)</td>
</tr>
<tr>
<td width="213" valign="top">Six Interrupt Sources</td>
<td width="213" valign="top">Eight Interrupt Sources</td>
<td width="213" valign="top">Six Interrupt Sources</td>
</tr>
<tr>
<td width="213" valign="top"> </td>
<td width="213" valign="top"> </td>
<td width="213" valign="top">On-chip Analog Comparator</td>
</tr>
</tbody>
</table>
<p><strong> </strong> </p>
<p><strong>AT89C2051 Pin Diagram and Description</strong></p>
<p style="text-align: center;"><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 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>VCC</p>
<p style="padding-left: 30px;">This pin is the supply voltage pin. The voltage range that can be supplied to this pin is from 2.7 volts to 6 volts but the most commonly used is 5 volts. Just remember to put a decoupling capacitor across this pin to filter out sudden voltage changes in the supply line and put the capacitor as close to VCC pin as possible. Typical values for the capacitor is 100nF.</p>
<p>GND</p>
<p style="padding-left: 30px;">This is the pin for ground.</p>
<p>XTAL1 &amp; XTAL2</p>
<p style="text-align: left; padding-left: 30px;">These are the input and output, respectively, of the inverting oscillator amplier located inside AT89C2051. The inverting oscillator amplier can be used as an on-chip oscillator as shown below. Either a quartz crystal or a ceramic resonator may be used. The values of C1 and C2 can be from 20pF to 40pF if a quartz crystal is used and 30pF to 50pF if a ceramic oscillator is used. Frequencies can be up to 24MHz.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-109" title="AT89C2051-oscillator" src="http://voltsandbytes.com/wp-content/uploads/2010/07/AT89C2051-oscillator.jpg" alt="" width="600" height="324" /></p>
<p style="padding-left: 30px;">The device can also be driven by an external clock source. Just connect the external clock source to XTAL1 and leave XTAL2 unconnected.</p>
<p style="text-align: center;"> </p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-111" title="AT89C2051- clock" src="http://voltsandbytes.com/wp-content/uploads/2010/07/AT89C2051-clock.png" alt="" width="600" height="324" /></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>RST</p>
<p style="padding-left: 30px;">This is the input for device reset. The device is being reset as soon as the RST pin goes HIGH.</p>
<p style="padding-left: 30px;">There is one thing that must be considered for this pin. The  AT89C2051 must operate as intended as soon as it is powered up. To be able to make that happen, AT89C2051 must perform the first instruction located in its program memory. Therefore, the MCU must undergo a reset upon powering up and this is called the <strong>power-on reset</strong>. The power-on reset for AT89C2051 will only occur when there is a capacitor across VCC and RST pin and a pulldown resitor from RST to ground. The typical configuration for the RST is shown below.</p>
<p style="text-align: center;"> <img class="aligncenter size-full wp-image-113" title="AT89C2051- reset" src="http://voltsandbytes.com/wp-content/uploads/2010/07/AT89C2051-reset.png" alt="" width="600" height="335" /></p>
<p>P1.0 – P1.7</p>
<p style="padding-left: 30px;">Pins <strong>P1.0</strong> to <strong>P1.7</strong> are the pins of <strong>Port1</strong>. These pins are bidirectional which means any pin of <strong>Port1</strong> can be used as an input pin or an output pin. Pins <strong>P1.2</strong> to <strong>P1.7</strong> have internal pullups but pins<strong> P1.0</strong> and <strong>P1.1</strong> require external pullups. However, pins <strong>P1.0</strong> and <strong>P1.1</strong> 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>P3.0 - P3.7</p>
<p style="text-align: left; padding-left: 60px;">Pins <strong>P3.0</strong> to <strong>P3.7</strong> are the pins of <strong>Port3</strong>. Like the <strong>Port1</strong>, <strong>Port3</strong> is also bidirectional and all pins have internal pullups. <strong>P3.6</strong> can not be accessed externally because it is hard-wired internally to the output of the on-chip analog comparator. Other functions of the pins of <strong>Port3</strong> are shown below: </p>
<table style="text-align: left;" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="text-align: center;" width="115" valign="top"><strong>Port Pin</strong></td>
<td style="text-align: center;" width="408" valign="top"><strong>Alternate Functions</strong></td>
</tr>
<tr>
<td style="text-align: center;" width="115" valign="top">P1.0</td>
<td width="408" valign="top">AIN0 (positive input) of the on-chip precision analog comparator</td>
</tr>
<tr>
<td style="text-align: center;" width="115" valign="top">P1.1</td>
<td width="408" valign="top">AIN1 (negative input) of the on-chip precision analog comparator</td>
</tr>
<tr>
<td style="text-align: center;" width="115" valign="top">P3.0</td>
<td width="408" valign="top">RXD (serial input port)</td>
</tr>
<tr>
<td style="text-align: center;" width="115" valign="top">P3.1</td>
<td width="408" valign="top">TXD (serial output port)</td>
</tr>
<tr>
<td style="text-align: center;" width="115" valign="top">P3.2</td>
<td width="408" valign="top">INT0 (external interrupt 0)</td>
</tr>
<tr>
<td style="text-align: center;" width="115" valign="top">P3.3</td>
<td width="408" valign="top">INT1 (external interrupt 1)</td>
</tr>
<tr>
<td style="text-align: center;" width="115" valign="top">P3.4</td>
<td width="408" valign="top">T0 (timer 0 external input)</td>
</tr>
<tr>
<td style="text-align: center;" width="115" valign="top">P3.5</td>
<td width="408" valign="top">T1 (timer 1 external input)</td>
</tr>
</tbody>
</table>
<p style="text-align: center;"><strong> </strong><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 style="text-align: left;"><strong>AT89C2051 Basic Hardware Configuration</strong></p>
<p style="text-align: left;"><img class="aligncenter size-full wp-image-123" title="AT89C2051- basic" src="http://voltsandbytes.com/wp-content/uploads/2010/07/AT89C2051-basic.png" alt="" width="600" height="321" /></p>
<p style="text-align: left;">The image above shows the summary of what was just discussed and it shows the basic hardware configuration to make AT89C2051 work.</p>
]]></content:encoded>
			<wfw:commentRss>http://voltsandbytes.com/8051-tutorial-1-introduction-to-at89c2051/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
