Embedded Freaks..

August 5, 2008

Setting external interrupt in AVR

Filed under: avr — Tags: — kunilkuda @ 5:47 am

The correct way to set up the (falling edge triggered) external interrupt in AVR is (using INT4 as example):


// Set INT4 as falling edge triggered
EICRB |= (2 << ISC40);

// Enable INT4 interrupt
EIMSK |= (1 << INT4);

The wrong way to set up falling edge triggered external interrupt in AVR:


// Enable PE4/INT4 as input
DDRE  &= ~(1 << PE4);
PORTE |=  (1 << PE4);

// Set INT4 as falling edge triggered
EICRB |= (1 << ISC41);

// Enable INT4 interrupt
EIMSK |= (1 << INT4);

Using the wrong way, you’ll miss a lot of falling edge interrupt. I’ve tried this once.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: