pls help....8051 external interrupts

Discussion in 'Embedded Systems and Microcontrollers' started by brucewayne, Aug 25, 2008.

  1. brucewayne

    Thread Starter New Member

    Aug 25, 2008
    3
    0
    i have used both the external interrupts ex0 and ex1 in the low level triggered mode. whenever either interrupt occurs, the LED on the output port is switched on, depending upon the input at pin P3.2.if that is high the led should switch on,when it is low it should switch off.

    but the problem i am facing is, the led switches on fine, but it switches off only 6-7 out of 10 times, and the phenomenon is absolutely random,no fixed pattern.(switching on is perfect,switching off is erratic)

    please help how to solve the problem of switching the led on and off at all interrupts(depending on the input value 'a' at that instant.)

    void ex0_isr (void) interrupt 0
    { if(a==1) //a is input bit at P3.2
    { sfwd=1;//led outputs at P1.0 and P1.1
    srev=0;
    }
    else
    { sfwd=0; srev=0; }
    }
    void main()
    { P3=0xFF; P1=0x00;
    while(1) {
    EA=1; // Configure interrupt 0 for falling edge on /INT0 (P3.2)
    EX0 = 1; // Enable EX0 Interrupt
    EX1 = 1;
    }
    }
     
    Last edited: Aug 25, 2008
  2. alitex

    Active Member

    Mar 5, 2007
    122
    0
    there are many reasons for ur problem,
    check the state of interrupts, if u want to respond to falling edg you should pull the pull-up resistor's port,
    check the state port is it input our output,so u should make it as input as u know,ok if u want to know more informations about external/internal interrupts read the datasheet.
     
  3. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    Used CODE tags to enhance readability of program code snippet.

    hgmjr
     
  4. Arm_n_Legs

    Active Member

    Mar 7, 2007
    183
    10
    You said you used two interrupts, but your sample program only has a interrupt service routine for external interrupt 0. What happen when there is an external interrupt 1?
     
Loading...