Maker Pro
Maker Pro

AVR external interrupt 0 problem

Please read the program below:
----------------------------------------------------------------------------------------------------------------------------------
#include <mega32.h>

// External Interrupt 0 service routine
interrupt [EXT_INT0] void ext_int0_isr(void)
{
PORTC = 0xaa;

}

// Declare your global variables here

void main(void)
{

// External Interrupt(s) initialization
// INT0: On
// INT0 Mode: Falling Edge
// INT1: Off
// INT2: Off
GICR|=0x40;
MCUCR=0x02;
MCUCSR=0x00;
GIFR=0x40;


// Global enable interrupts
#asm("sei")
DDRC = 0xff;//configuring PORTC as output to test
while (1)
{
// Place your code here

};
}

----------------------------------------------------------------------------------------------------------------------------------

according to the program pasted above, the PORTC pins should give output 0xaa only when INT0 pin gets a falling edge. But in my case, PORTC is enabled forever. I have tried multiple combinations like level triggered , rising edge etc.. but all are giving the same output. Please reply.
 
Top