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.

avr external interrupt not working

Status
Not open for further replies.

abilashjoseph

Member level 1
Joined
Sep 8, 2009
Messages
34
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Kerala
Activity points
1,560
hi,
i am using the interrupt in avr atmega16, while compiling the code there is no error , but at simulation the interrupt is not working. the code is given below. please help me, thanks.

#include <avr/io.h>
#include <avr/interrupt.h>
volatile int pulses=0;
ISR(INT1_vect)
{
pulses++;
}


int main(void)
{

int j =0;
int k ;
int l=0;
int m;
int i=0;
int g;
DDRB =0xff;
DDRD =0xf3;
DDRC = 0xff;
SREG =0x80;
GICR = 0xC0;
MCUCR = 0x05;

sei();
while(1)
{

PORTC = pulses;

cli();

}
}
 

sei(); enables the global interrupt flag
and cli(); disables the global interrupt flag.

As soon as you apply the cli(); all interrupts are disabled and I'm sure that it is executed before you have a chance to generate any interrupt.
If you want to disable the interrupts after the first interrupt then place it inside the interrupt routine.

Alex
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top