Discussion in "8051 Discussion Forum" started by    bobparihar    Sep 15, 2014.
Mon Sep 15 2014, 11:54 am
#1
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;
}
}
Wed Sep 17 2014, 10:15 am
#2
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
}

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am