This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

pls help...external interrupts 8051

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; }
}

Parents Reply Children
  • I think Erik meant that

    if the pulse is to short, you will never see it as a 1.
    Depending on the clock speed of your 8051, you may well be into the interrupt after the signal has gone away.

    there is a way to do this, but you have to burn both external interrupts. You take your interrupt signal in, and run it through an inverter and tie that to the other external interrupt. Program them both for negative going edge sensitive interrupts. If the edge is a falling one, you will get interupt 1 for example.
    Since you know the edge was falling, and this is the non-inverted interrupt, you know that the status of the pin is low. If you get the other one, you know that the status of the pin would be high (the inverter will cause a one or the other of these interrupts to happen on every signal. The signal may go away, but by virtue of the fact that you are in one interrupt or the other, you can figure that out.

    hope that helps.
    Cheers