Programming external interrupt 0
Discussion in "8051 Discussion Forum" started by bobparihar Sep 15, 2014.
Mon Sep 15 2014, 11:54 am
i am programming interrupt 0 using 8051
my task is.. explained in the circuit diagram as follows
when ever till the push button pressed the led should goes low which is connected at P2.1
but the problem i am facing is if long press the button the led toggles quickly and repeatedly... but i want that till the button is pressed the led should be off
here is my code
CODE/
#include<reg51.h>
sbit a=P2^1; // for led
void ext(void) interrupt 0
{
a=0;
}
void main()
{
IE=0x81; // using external 0 interrupt
while(1)
{
a=1;
}
}
my task is.. explained in the circuit diagram as follows
when ever till the push button pressed the led should goes low which is connected at P2.1
but the problem i am facing is if long press the button the led toggles quickly and repeatedly... but i want that till the button is pressed the led should be off
here is my code
CODE/
#include<reg51.h>
sbit a=P2^1; // for led
void ext(void) interrupt 0
{
a=0;
}
void main()
{
IE=0x81; // using external 0 interrupt
while(1)
{
a=1;
}
}
Wed Sep 17 2014, 10:15 am
you need to put a wait condition in ISR till the switch is released e.g.
void ext(void) interrupt 0 { a=0; while (!P3^2); //wait for pin to go high }
Powered by e107 Forum System