<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Timers in Compare Mode – Part I</title>
	<atom:link href="http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/feed/" rel="self" type="application/rss+xml" />
	<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/</link>
	<description></description>
	<lastBuildDate>Sat, 19 May 2012 21:55:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: taiwofolu</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-40029</link>
		<dc:creator>taiwofolu</dc:creator>
		<pubDate>Tue, 10 Apr 2012 12:07:26 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-40029</guid>
		<description>Hello Avinash! Keep up the good work! I&#039;m doing this as a personal project but I need some assistance. I had to do some  reading and research of my own before asking any questions because many terms weren&#039;t clear to me. Thanks to your site I now understand a whole lot of things. After my study, I wrote this code:  


/*PROGRAM WRITTEN BY TAIWO FOLU. PWM CONTROL OVER BLUETOOTH WITH DTMF TONES. INPUT ON ATTINY2313 PINS PB4 TO PB7. PWM SIGNAL OUTPUT ON PB2 (OC0A) AND PD5 (OC0B) USING TIMER0. TWO EXTRA I/O PINS ON PB0 AND PB1*/

#include 
 void initPWM()
{
 TCCR0&#124;=(1&lt;&lt;WGM01)&#124;(1&lt;&lt;COM01)&#124;(1&lt;&lt;CS00);
//Freq=FCPU, phase correct pwm, non inverted PWM (mode3)
 DDRB&#124;=0xE0; //Set PB0, PB1 and PB2 for output and the rest for input
 DDRD&#124;=(1&lt;&lt;PD5); //Set PD5 for output
}
 void SetPWMOutput(Uint8_t duty)
{
 OCR0A=0; //Set dutyA to 0%
 OCR0B=127; //Set dutyB to 50%
}
 void main()
{
 Unsinged int f;
 while (1)
{
 f=PINB;
 switch (f)
 {
  case 0x04: //when key 4 is pressed
  {
   OCR0B++; //increment OCR0B
   break;
  }
  case 0x05: //when key 5 is pressed
  {
   OCR0A++; //increment OCR0A
   break;
  }
  case 0x06: //when key 6 is pressed
  {
   OCRB--; //decrement OCR0B
   break;
  }
  case 0x0A: //when key0 is pressed
  {
   OCR0A--; //decrement OCR0A
   break;
  }
 }
}[/syntax]
     



I intend to use the dtmf tones to control the duty cycles of pwm channels A and B on timer0. Please look through the code and help me if i&#039;ve made any mistakes or unnecessary statements or he there&#039;s a better way to implement this. Here, i&#039;ve not used the PB0 and PB1 pins yet so I don&#039;t get confused, I want to get the duty cycles control right first. 
Thanks a lot.</description>
		<content:encoded><![CDATA[<p>Hello Avinash! Keep up the good work! I&#8217;m doing this as a personal project but I need some assistance. I had to do some  reading and research of my own before asking any questions because many terms weren&#8217;t clear to me. Thanks to your site I now understand a whole lot of things. After my study, I wrote this code:  </p>
<p>/*PROGRAM WRITTEN BY TAIWO FOLU. PWM CONTROL OVER BLUETOOTH WITH DTMF TONES. INPUT ON ATTINY2313 PINS PB4 TO PB7. PWM SIGNAL OUTPUT ON PB2 (OC0A) AND PD5 (OC0B) USING TIMER0. TWO EXTRA I/O PINS ON PB0 AND PB1*/</p>
<p>#include<br />
 void initPWM()<br />
{<br />
 TCCR0|=(1&lt;&lt;WGM01)|(1&lt;&lt;COM01)|(1&lt;&lt;CS00);<br />
//Freq=FCPU, phase correct pwm, non inverted PWM (mode3)<br />
 DDRB|=0xE0; //Set PB0, PB1 and PB2 for output and the rest for input<br />
 DDRD|=(1&lt;&lt;PD5); //Set PD5 for output<br />
}<br />
 void SetPWMOutput(Uint8_t duty)<br />
{<br />
 OCR0A=0; //Set dutyA to 0%<br />
 OCR0B=127; //Set dutyB to 50%<br />
}<br />
 void main()<br />
{<br />
 Unsinged int f;<br />
 while (1)<br />
{<br />
 f=PINB;<br />
 switch (f)<br />
 {<br />
  case 0&#215;04: //when key 4 is pressed<br />
  {<br />
   OCR0B++; //increment OCR0B<br />
   break;<br />
  }<br />
  case 0&#215;05: //when key 5 is pressed<br />
  {<br />
   OCR0A++; //increment OCR0A<br />
   break;<br />
  }<br />
  case 0&#215;06: //when key 6 is pressed<br />
  {<br />
   OCRB&#8211;; //decrement OCR0B<br />
   break;<br />
  }<br />
  case 0x0A: //when key0 is pressed<br />
  {<br />
   OCR0A&#8211;; //decrement OCR0A<br />
   break;<br />
  }<br />
 }<br />
}[/syntax]</p>
<p>I intend to use the dtmf tones to control the duty cycles of pwm channels A and B on timer0. Please look through the code and help me if i&#039;ve made any mistakes or unnecessary statements or he there&#039;s a better way to implement this. Here, i&#039;ve not used the PB0 and PB1 pins yet so I don&#039;t get confused, I want to get the duty cycles control right first.<br />
Thanks a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Awais Khan</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-37952</link>
		<dc:creator>Awais Khan</dc:creator>
		<pubDate>Sat, 21 Jan 2012 12:59:13 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-37952</guid>
		<description>Hello
    Timer tutorial was very beneficial to me. I wanna use AVR ATmega32 for page writing and page reading on AT24C1024 EEPROM. Is there any tutorial for that?</description>
		<content:encoded><![CDATA[<p>Hello<br />
    Timer tutorial was very beneficial to me. I wanna use AVR ATmega32 for page writing and page reading on AT24C1024 EEPROM. Is there any tutorial for that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: prakash</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-37562</link>
		<dc:creator>prakash</dc:creator>
		<pubDate>Wed, 11 Jan 2012 04:44:58 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-37562</guid>
		<description>THnks,sir</description>
		<content:encoded><![CDATA[<p>THnks,sir</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vinayak</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-36802</link>
		<dc:creator>vinayak</dc:creator>
		<pubDate>Wed, 28 Dec 2011 06:11:22 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-36802</guid>
		<description>hi Avinash
i am looking for touch screen interface to atmega32 
can you give me suggestion for this type implementation or can you give demo board for this 
please give me reply</description>
		<content:encoded><![CDATA[<p>hi Avinash<br />
i am looking for touch screen interface to atmega32<br />
can you give me suggestion for this type implementation or can you give demo board for this<br />
please give me reply</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matrix</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-36203</link>
		<dc:creator>matrix</dc:creator>
		<pubDate>Thu, 22 Dec 2011 06:27:57 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-36203</guid>
		<description>MIND-BLOWING explanation.....u make topics so simple..doesn&#039;t matter how hard the topic is. THUMBS UP 4 U. (*****)</description>
		<content:encoded><![CDATA[<p>MIND-BLOWING explanation&#8230;..u make topics so simple..doesn&#8217;t matter how hard the topic is. THUMBS UP 4 U. (*****)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thong</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-33182</link>
		<dc:creator>Thong</dc:creator>
		<pubDate>Tue, 22 Nov 2011 14:13:01 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-33182</guid>
		<description>Hi everyone
I don&#039;t understand the thing which is written in ATmega128 Data Sheet page 93 :
&quot;Changing the TOP to a value close to BOTTOM
when the counter is running with none or a low prescaler value must be done with care since the CTC mode does not have the double buffering feature. If the new value written to OCR0 is lower than the current value of TCNT0, the counter will miss the compare match. The counter will then have to count to its maximum value (0xFF) and wrap around starting at 0x00 before the compare match can occur.&quot;
Why? and if in CTC mode have the double buffering. What is happen different?
Thanks</description>
		<content:encoded><![CDATA[<p>Hi everyone<br />
I don&#8217;t understand the thing which is written in ATmega128 Data Sheet page 93 :<br />
&#8220;Changing the TOP to a value close to BOTTOM<br />
when the counter is running with none or a low prescaler value must be done with care since the CTC mode does not have the double buffering feature. If the new value written to OCR0 is lower than the current value of TCNT0, the counter will miss the compare match. The counter will then have to count to its maximum value (0xFF) and wrap around starting at 0&#215;00 before the compare match can occur.&#8221;<br />
Why? and if in CTC mode have the double buffering. What is happen different?<br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Armen</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-25688</link>
		<dc:creator>Armen</dc:creator>
		<pubDate>Mon, 11 Jul 2011 13:00:28 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-25688</guid>
		<description>Tremendous Tutorial, clean, simple, easy to get, cool table color filterm, ... 
Thank you.
awsome job!</description>
		<content:encoded><![CDATA[<p>Tremendous Tutorial, clean, simple, easy to get, cool table color filterm, &#8230;<br />
Thank you.<br />
awsome job!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eeshaanee</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-23421</link>
		<dc:creator>Eeshaanee</dc:creator>
		<pubDate>Mon, 13 Jun 2011 16:54:33 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-23421</guid>
		<description>very nice tutorials....
really well explained..!!</description>
		<content:encoded><![CDATA[<p>very nice tutorials&#8230;.<br />
really well explained..!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AVR Timers - An Introduction. &#124; eXtreme Electronics</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-22399</link>
		<dc:creator>AVR Timers - An Introduction. &#124; eXtreme Electronics</dc:creator>
		<pubDate>Thu, 02 Jun 2011 04:33:13 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-22399</guid>
		<description>[...] Timers in Compare Mode [...]</description>
		<content:encoded><![CDATA[<p>[...] Timers in Compare Mode [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hans</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-19012</link>
		<dc:creator>hans</dc:creator>
		<pubDate>Fri, 18 Mar 2011 10:37:32 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-19012</guid>
		<description>Well done! keep up the pace. we&#039;re looking forward to get a pdf of this part and the next parts.</description>
		<content:encoded><![CDATA[<p>Well done! keep up the pace. we&#8217;re looking forward to get a pdf of this part and the next parts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Avinash</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-16749</link>
		<dc:creator>Avinash</dc:creator>
		<pubDate>Fri, 21 Jan 2011 06:54:27 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-16749</guid>
		<description>&lt;strong&gt;@Micro,

Thanks a lot for your feedback! Only people like you provide energy to keep me writing ...
&lt;/strong&gt;</description>
		<content:encoded><![CDATA[<p><strong>@Micro,</p>
<p>Thanks a lot for your feedback! Only people like you provide energy to keep me writing &#8230;<br />
</strong></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Micro</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-16746</link>
		<dc:creator>Micro</dc:creator>
		<pubDate>Fri, 21 Jan 2011 05:39:11 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-16746</guid>
		<description>I have read both your timer tutorials.  These are the best I found.  After reading these I was finally able to understand the datasheets.  This helped me a ton.  Thanks</description>
		<content:encoded><![CDATA[<p>I have read both your timer tutorials.  These are the best I found.  After reading these I was finally able to understand the datasheets.  This helped me a ton.  Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Siddhartha</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-16320</link>
		<dc:creator>Siddhartha</dc:creator>
		<pubDate>Sat, 08 Jan 2011 07:55:44 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-16320</guid>
		<description>In case the following points help someone :

-----------------------------------------------------------
&quot;In the above setup if I vary OCR1B, will I get a Fast PWM on OC1B, whose duty I can vary independent of OCR1A.&quot;

I tried. Yes it can be done.
-----------------------------------------------------------
&quot;In that case I can use OC1A and OC1B to drive the two ENABLE pins of LM293D (motor driver) independently.&quot;

I have still not tried. But I am sure it can be done.
-----------------------------------------------------------</description>
		<content:encoded><![CDATA[<p>In case the following points help someone :</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8220;In the above setup if I vary OCR1B, will I get a Fast PWM on OC1B, whose duty I can vary independent of OCR1A.&#8221;</p>
<p>I tried. Yes it can be done.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
&#8220;In that case I can use OC1A and OC1B to drive the two ENABLE pins of LM293D (motor driver) independently.&#8221;</p>
<p>I have still not tried. But I am sure it can be done.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Siddhartha</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-16177</link>
		<dc:creator>Siddhartha</dc:creator>
		<pubDate>Tue, 04 Jan 2011 05:45:07 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-16177</guid>
		<description>The one of the very exceptional works I have ever seen on AVR tutorials. 

Greetings for the new year to all.

I am using Atmega16 with 8 Mhz external crystal. I have been able to set the Timer1 prescaler and Fast PWM mode. By varying OCR1A and I could vary the duty of Fast PWM on OC1A.

My query is as follows : 
In the above setup if I vary OCR1B, will I get a Fast PWM on OC1B, whose duty I can vary independent of OCR1A. In that case I can use OC1A and OC1B to drive the two ENABLE pins of LM293D (motor driver) independently.

Let me know if the above concept is valid.

Thank you.</description>
		<content:encoded><![CDATA[<p>The one of the very exceptional works I have ever seen on AVR tutorials. </p>
<p>Greetings for the new year to all.</p>
<p>I am using Atmega16 with 8 Mhz external crystal. I have been able to set the Timer1 prescaler and Fast PWM mode. By varying OCR1A and I could vary the duty of Fast PWM on OC1A.</p>
<p>My query is as follows :<br />
In the above setup if I vary OCR1B, will I get a Fast PWM on OC1B, whose duty I can vary independent of OCR1A. In that case I can use OC1A and OC1B to drive the two ENABLE pins of LM293D (motor driver) independently.</p>
<p>Let me know if the above concept is valid.</p>
<p>Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sai</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-14921</link>
		<dc:creator>sai</dc:creator>
		<pubDate>Sat, 04 Dec 2010 05:46:20 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-14921</guid>
		<description>damn good,really useful.clean ,ssimple,superb.thanks a lot</description>
		<content:encoded><![CDATA[<p>damn good,really useful.clean ,ssimple,superb.thanks a lot</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mayank Sharma</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-13637</link>
		<dc:creator>Mayank Sharma</dc:creator>
		<pubDate>Tue, 19 Oct 2010 13:38:18 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-13637</guid>
		<description>all these tutorials here are best on net</description>
		<content:encoded><![CDATA[<p>all these tutorials here are best on net</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Interfacing Ultrasonic Rangefinder with AVR MCUs &#124; eXtreme Electronics</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-13317</link>
		<dc:creator>Interfacing Ultrasonic Rangefinder with AVR MCUs &#124; eXtreme Electronics</dc:creator>
		<pubDate>Thu, 07 Oct 2010 02:52:03 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-13317</guid>
		<description>[...] Timers in Compare Mode [...]</description>
		<content:encoded><![CDATA[<p>[...] Timers in Compare Mode [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William Lewis</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-11686</link>
		<dc:creator>William Lewis</dc:creator>
		<pubDate>Sat, 21 Aug 2010 16:44:42 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-11686</guid>
		<description>Excellent.. Just what i was looking for</description>
		<content:encoded><![CDATA[<p>Excellent.. Just what i was looking for</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sam</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-10228</link>
		<dc:creator>sam</dc:creator>
		<pubDate>Tue, 06 Jul 2010 17:40:11 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-10228</guid>
		<description>Hi 
A wonderful job done by you.. amazing
I have made a program for my project in which i require the microcontroller to perform the following functions:
1)pulse generation
2)timer to ADC9220 
3)data acquisition from the 12 bit adc.
can you check my code whether it is fine. i will be gratefull.</description>
		<content:encoded><![CDATA[<p>Hi<br />
A wonderful job done by you.. amazing<br />
I have made a program for my project in which i require the microcontroller to perform the following functions:<br />
1)pulse generation<br />
2)timer to ADC9220<br />
3)data acquisition from the 12 bit adc.<br />
can you check my code whether it is fine. i will be gratefull.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mayank</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/timers-in-compare-mode-part-i/comment-page-1/#comment-9128</link>
		<dc:creator>Mayank</dc:creator>
		<pubDate>Tue, 08 Jun 2010 17:41:30 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=31#comment-9128</guid>
		<description>well, actually, i use a microcontroller development board, which I bought from somewhere else. They have attached the 4Mhz crystal and given to me. So, i feel that they have had preset the fuse bits for that. Anyways, i will recheck that part. 

One reason that i could find for the slow process was a fault in the programming. 1sec = 100msec, but in your code (part II), 1000msec was used. But after that, the clock became too fast.. approx, it took 4sec to complete 10sec of display.</description>
		<content:encoded><![CDATA[<p>well, actually, i use a microcontroller development board, which I bought from somewhere else. They have attached the 4Mhz crystal and given to me. So, i feel that they have had preset the fuse bits for that. Anyways, i will recheck that part. </p>
<p>One reason that i could find for the slow process was a fault in the programming. 1sec = 100msec, but in your code (part II), 1000msec was used. But after that, the clock became too fast.. approx, it took 4sec to complete 10sec of display.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Database Caching 11/34 queries in 0.010 seconds using apc
Object Caching 548/550 objects using disk: basic

Served from: extremeelectronics.co.in @ 2012-05-22 08:42:17 -->
