<?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; Interrupt</title>
</title>
	<atom:link href="http://voltsandbytes.com/tag/interrupt/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>
	</channel>
</rss>
