Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

interrupt program in avr(atmega16)

Status
Not open for further replies.

jeevan19

Newbie level 1
Newbie level 1
Joined
Dec 9, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
9
hi,i am new to avr programming, i tried this below code,,where in my main program i make sm bits toggle for 5 times,,and i give an external interrupt to INT1. In my interrupt routine,,i just give some delay of 10 secs..i tried in proteus. my interrupt is not called when i give high signal to int1 pin,..i tried these interrupts logic 1.any logic change makes interrupt request
2.rising edge gives interrupt request
3.falling edge gives interr request...........but none worked out,,SO PLEASE HELP ME IN THIS


my code,,,
Code:
#include <avr/io.h>
#include <avr/interrupt.h>
#define F_CPU 16000000UL
#include <util/delay.h>
void delay_ms(unsigned int d)
{
_delay_ms(d);
}

ISR(INT1_vect)
{
_delay_ms(6000);
_delay_ms(4000);
}

int main (void)
{
unsigned int i,j;
DDRC = 0xF0; 				//IN PORTC upper 4 bit is output and lower 4 bit is input
DDRD = 0X00;      			//portd as input

while(1) 
{

if(bit_is_clear(PINC,0))  		//if PORTC 0 PIN IS LOW
{
for(i=0;i<4;i++)
{
PORTC=0X40;
_delay_ms(1000);
PORTC=0X00;
_delay_ms(1000);
}

GICR = 1<<INT1;					// Enable INT0
MCUCR = 1<<ISC11 | 0<<ISC10;			// Trigger INT0 on any logic change
sei();						//enable global interrupt

for(j=0;j<4;j++)
{
_delay_ms(2000);
}
PORTC=0X80;
_delay_ms(2000);
PORTC=0X00;
}
else
PORTC=0X00;
}
return 1;
}
 
Last edited by a moderator:

Execute the main logic inside the Interrupt Service Routine and as u have declared the condition to start an ISR and global Interrupt bit enable then just include

while(1);
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top