pls help....8051 ext. interrupts

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


  • I take it you made all variables, including the register definitions, volatile?
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion