<?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; Counter</title>
</title>
	<atom:link href="http://voltsandbytes.com/tag/counter/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 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>0</slash:comments>
		</item>
	</channel>
</rss>
