<?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: External Interrupts on an ATmega168</title>
	<atom:link href="http://www.protostack.com/blog/2010/09/external-interrupts-on-an-atmega168/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.protostack.com/blog/2010/09/external-interrupts-on-an-atmega168/</link>
	<description>Atmega168 development kits, AVR Development boards, Prototyping boards and Electronic components</description>
	<lastBuildDate>Tue, 26 Mar 2013 12:09:58 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: samim</title>
		<link>http://www.protostack.com/blog/2010/09/external-interrupts-on-an-atmega168/#comment-311037</link>
		<dc:creator>samim</dc:creator>
		<pubDate>Tue, 26 Mar 2013 12:09:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.protostack.com/blog/?p=209#comment-311037</guid>
		<description>i can&#039;t understand _BV() !!! what it mean?  plz explain it . don&#039;t take the question  any way because i&#039;m a novice in AVR system :)</description>
		<content:encoded><![CDATA[<p>i can&#8217;t understand _BV() !!! what it mean?  plz explain it . don&#8217;t take the question  any way because i&#8217;m a novice in AVR system <img src='http://www.protostack.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.protostack.com/blog/2010/09/external-interrupts-on-an-atmega168/#comment-35353</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Fri, 14 Sep 2012 14:26:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.protostack.com/blog/?p=209#comment-35353</guid>
		<description>Thankyou very much! This had the two missing lines of code I needed: 18 and 19.</description>
		<content:encoded><![CDATA[<p>Thankyou very much! This had the two missing lines of code I needed: 18 and 19.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MHeU</title>
		<link>http://www.protostack.com/blog/2010/09/external-interrupts-on-an-atmega168/#comment-33163</link>
		<dc:creator>MHeU</dc:creator>
		<pubDate>Wed, 11 Jul 2012 14:17:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.protostack.com/blog/?p=209#comment-33163</guid>
		<description>instead of CHECKBIT(PORTB, 0) you need to read the Pins with
CHECKBIT(PINB, 0)
have fun</description>
		<content:encoded><![CDATA[<p>instead of CHECKBIT(PORTB, 0) you need to read the Pins with<br />
CHECKBIT(PINB, 0)<br />
have fun</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: srbombaywala</title>
		<link>http://www.protostack.com/blog/2010/09/external-interrupts-on-an-atmega168/#comment-32901</link>
		<dc:creator>srbombaywala</dc:creator>
		<pubDate>Sat, 30 Jun 2012 07:56:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.protostack.com/blog/?p=209#comment-32901</guid>
		<description>include arv/io.h
        util/dealy.h
        avr/interrupt.h</description>
		<content:encoded><![CDATA[<p>include arv/io.h<br />
        util/dealy.h<br />
        avr/interrupt.h</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: srbombaywala</title>
		<link>http://www.protostack.com/blog/2010/09/external-interrupts-on-an-atmega168/#comment-32900</link>
		<dc:creator>srbombaywala</dc:creator>
		<pubDate>Sat, 30 Jun 2012 07:55:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.protostack.com/blog/?p=209#comment-32900</guid>
		<description>Hello there
i am using this code for toggling the leds.
________________________________________________
#include 
#include 

#include 

#define SETBIT(ADDRESS,BIT) (ADDRESS &#124;= (1&lt;&lt;BIT))
#define CLEARBIT(ADDRESS,BIT) (ADDRESS &amp;= ~(1&lt;&lt;BIT))
#define FLIPBIT(ADDRESS,BIT) (ADDRESS ^= (1&lt;&lt;BIT))
#define CHECKBIT(ADDRESS,BIT) (ADDRESS &amp; (1&lt;&lt;BIT))
#define WRITEBIT(RADDRESS,RBIT,WADDRESS,WBIT) (CHECKBIT(RADDRESS,RBIT) ? SETBIT(WADDRESS,WBIT) : CLEARBIT(WADDRESS,WBIT))
volatile int i=1;
int main(void)
{  
    DDRB &amp;= ~(1 &lt;&lt; DDB0);     // Clear the PB0 pin
    // PB0 (PCINT0 pin) is now an input

    PORTB &#124;= (1 &lt;&lt; PORTB0);    // turn On the Pull-up
    // PB0 is now an input with pull-up enabled
	DDRD = 0xFF;
    PORTD = 0xF9;

    PCICR &#124;= (1 &lt;&lt; PCIE0);    // set PCIE0 to enable PCMSK0 scan
    PCMSK0 &#124;= (1 &lt;&lt; PCINT0);  // set PCINT0 to trigger an interrupt on state change 

    sei();                    // turn on interrupts

    while(1)
    {
       
		if(i==0)
            {
                //i=0;
                SETBIT(PORTD,0);
                CLEARBIT(PORTD,1);
                CLEARBIT(PORTD,2);
            }
            else
                if(i==1)
                {
                    SETBIT(PORTD,1);
                    CLEARBIT(PORTD,2);
                    CLEARBIT(PORTD,0);
                }
                else
                {
                    SETBIT(PORTD,2);
                    CLEARBIT(PORTD,0);
                    CLEARBIT(PORTD,1);
                }
    }

}


ISR (PCINT0_vect)
{
   
   /*if(PORTB &amp; (1 &lt;&lt; PB0))
    {
        i++;
		if (i==3)
		i=0;
    }
    else
    {
        i=i;
    }*/
	if(!CHECKBIT(PORTB,0))
	{
	
    i++;
	if (i==3)
	i=0;
	}
	else
	{
	i=i;
	
	}

}
_________________________________________________
the switch is connected to PCINT0 (i.e. PortB0) and the led&#039;s are connected to PORTD0,1,2.
Since the switch press gives two interrupts (one high to low when pressed and other low to high when released ) the led&#039;s toggle by 2 instead of one.
I have used the for loop in the ISR but nothing seems to work
Kindly help</description>
		<content:encoded><![CDATA[<p>Hello there<br />
i am using this code for toggling the leds.<br />
________________________________________________<br />
#include<br />
#include </p>
<p>#include </p>
<p>#define SETBIT(ADDRESS,BIT) (ADDRESS |= (1&lt;&lt;BIT))<br />
#define CLEARBIT(ADDRESS,BIT) (ADDRESS &amp;= ~(1&lt;&lt;BIT))<br />
#define FLIPBIT(ADDRESS,BIT) (ADDRESS ^= (1&lt;&lt;BIT))<br />
#define CHECKBIT(ADDRESS,BIT) (ADDRESS &amp; (1&lt;&lt;BIT))<br />
#define WRITEBIT(RADDRESS,RBIT,WADDRESS,WBIT) (CHECKBIT(RADDRESS,RBIT) ? SETBIT(WADDRESS,WBIT) : CLEARBIT(WADDRESS,WBIT))<br />
volatile int i=1;<br />
int main(void)<br />
{<br />
    DDRB &amp;= ~(1 &lt;&lt; DDB0);     // Clear the PB0 pin<br />
    // PB0 (PCINT0 pin) is now an input</p>
<p>    PORTB |= (1 &lt;&lt; PORTB0);    // turn On the Pull-up<br />
    // PB0 is now an input with pull-up enabled<br />
	DDRD = 0xFF;<br />
    PORTD = 0xF9;</p>
<p>    PCICR |= (1 &lt;&lt; PCIE0);    // set PCIE0 to enable PCMSK0 scan<br />
    PCMSK0 |= (1 &lt;&lt; PCINT0);  // set PCINT0 to trigger an interrupt on state change </p>
<p>    sei();                    // turn on interrupts</p>
<p>    while(1)<br />
    {</p>
<p>		if(i==0)<br />
            {<br />
                //i=0;<br />
                SETBIT(PORTD,0);<br />
                CLEARBIT(PORTD,1);<br />
                CLEARBIT(PORTD,2);<br />
            }<br />
            else<br />
                if(i==1)<br />
                {<br />
                    SETBIT(PORTD,1);<br />
                    CLEARBIT(PORTD,2);<br />
                    CLEARBIT(PORTD,0);<br />
                }<br />
                else<br />
                {<br />
                    SETBIT(PORTD,2);<br />
                    CLEARBIT(PORTD,0);<br />
                    CLEARBIT(PORTD,1);<br />
                }<br />
    }</p>
<p>}</p>
<p>ISR (PCINT0_vect)<br />
{</p>
<p>   /*if(PORTB &amp; (1 &lt;&lt; PB0))<br />
    {<br />
        i++;<br />
		if (i==3)<br />
		i=0;<br />
    }<br />
    else<br />
    {<br />
        i=i;<br />
    }*/<br />
	if(!CHECKBIT(PORTB,0))<br />
	{</p>
<p>    i++;<br />
	if (i==3)<br />
	i=0;<br />
	}<br />
	else<br />
	{<br />
	i=i;</p>
<p>	}</p>
<p>}<br />
_________________________________________________<br />
the switch is connected to PCINT0 (i.e. PortB0) and the led&#039;s are connected to PORTD0,1,2.<br />
Since the switch press gives two interrupts (one high to low when pressed and other low to high when released ) the led&#039;s toggle by 2 instead of one.<br />
I have used the for loop in the ISR but nothing seems to work<br />
Kindly help</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oscar</title>
		<link>http://www.protostack.com/blog/2010/09/external-interrupts-on-an-atmega168/#comment-21604</link>
		<dc:creator>Oscar</dc:creator>
		<pubDate>Fri, 24 Feb 2012 16:08:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.protostack.com/blog/?p=209#comment-21604</guid>
		<description>Great article.

I come from PIC and I see some coincidences: INT0 for pin RB0 and PCINT0 for pin RB4-RB7.

Thanks to you I can understand the power of AVR interrupts.</description>
		<content:encoded><![CDATA[<p>Great article.</p>
<p>I come from PIC and I see some coincidences: INT0 for pin RB0 and PCINT0 for pin RB4-RB7.</p>
<p>Thanks to you I can understand the power of AVR interrupts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dr. Bob Bob</title>
		<link>http://www.protostack.com/blog/2010/09/external-interrupts-on-an-atmega168/#comment-531</link>
		<dc:creator>Dr. Bob Bob</dc:creator>
		<pubDate>Mon, 27 Sep 2010 20:10:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.protostack.com/blog/?p=209#comment-531</guid>
		<description>Good post.  I am a PIC guy myself but I know enough about microcontrollers to know that interrupts are very important.  I rarely use external interrupts because of signal bounce.  You could write a pretty good article about that issue alone.

Another article that would be interesting would be on other peripheral interrupts (ex timers and serial data).  I find those interrupts to be much more interesting than external interrupts.</description>
		<content:encoded><![CDATA[<p>Good post.  I am a PIC guy myself but I know enough about microcontrollers to know that interrupts are very important.  I rarely use external interrupts because of signal bounce.  You could write a pretty good article about that issue alone.</p>
<p>Another article that would be interesting would be on other peripheral interrupts (ex timers and serial data).  I find those interrupts to be much more interesting than external interrupts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brad</title>
		<link>http://www.protostack.com/blog/2010/09/external-interrupts-on-an-atmega168/#comment-206</link>
		<dc:creator>Brad</dc:creator>
		<pubDate>Thu, 09 Sep 2010 12:43:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.protostack.com/blog/?p=209#comment-206</guid>
		<description>Hey, thanks for this explanation and example. I&#039;m just starting out with AVR gear, and this helps a lot.
Thanks again</description>
		<content:encoded><![CDATA[<p>Hey, thanks for this explanation and example. I&#8217;m just starting out with AVR gear, and this helps a lot.<br />
Thanks again</p>
]]></content:encoded>
	</item>
</channel>
</rss>
