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 0 problem

Status
Not open for further replies.

saurabh17g

Member level 2
Joined
Mar 30, 2010
Messages
49
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Bombay
Activity points
1,707
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.
 

According to your program PORTC is always 0xaa after the first INT0. The program never changes this value again. Try to change the value inside the while loop (e.g. PORTC = 0x55). In this case, value 0xaa will be seen at the output only during INT0 execution (a very short time).
Regards
 

yes, i modified the program as:

{
PORTC = 0xaa;
delay_ms(500);
PORTC =0x55;
}

but the outcome is same. I am getting PORTC as all 0xff(combination of 0x55 and oxaa) whether or not interrupt is triggered.
 

Is there anything that is functioning properly? Seems the reset pin is held ON.

Added after 3 minutes:

Also confirm BROWN OUT is not activated.

Added after 3 minutes:

A doubt: which version of Codevision are you using?
 

Did you disabled JTAG. The jtag pins are at PORTC

Try using other port like PORTA

Tested with simulation and your code working properly
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top