Connect with us

AVR external interrupt 0 problem

Discussion in 'Microcontrollers, Programming and IoT' started by saurabh17g, Apr 26, 2010.

  1. saurabh17g

    saurabh17g

    72
    0
    Mar 8, 2010
    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.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-