Need "debouncing Code" in C++ For Interrupt routine - Urgent !!

The way I have my code is such that when there is an interrupt in the p0.5 , pin
The ISR works - which is to BLINK an LED. on p1.3.


Now what I want to do is that i need to make sure the edge has been triggered or not , so I want to add a 1 second delay after which the cpu checks if the interrupt is still true or not and proceeds with the ISR.

so basically . here's my working code -- I need to add debounce code in here.
//------------------------------------------------------------------
#include
#define SYSCLK 245000000
sbit SW1 = P0^5;
sbit LED = P1^3;
void Oscillator_Init (void); // Initiating Oscillator,Ports & Interrupts.
void Port_Init (void);
void Ext_Interrupt_Init (void);

void main (void)
{
PCA0MD &= ~0x40;
Oscillator_Init();
Port_Init ();
Ext_Interrupt_Init();
EA = 1;
while(1);

}
void Oscillator_Init (void)
{
OSCICN = 0x83;

}
void Port_Init (void)
{
XBR1 = 0x40;
P0SKIP = 0x20; // input is p0.5 , digital , open drain
P1MDOUT = 0x08; // led digital , push pull p1.3
}
void Ext_Interrupt_Init (void)
{
TCON = 0x01; //INT0 , active low
IT01CF = 0x05;

EX0 = 1; // Enable int0
}
void INT0_ISR (void) interrupt 0
{ // I need a debounce code here
LED = !LED;
}
//---------------------------------------------------------------------


How do I write this ?? I would really appreciate any help .

Replies

You are reading an archived discussion.

Related Posts

hiiiiii i need your helpppp plzzz 😕 1- what should be the PIV rating of diodes in the circuit ? 2- if one of the diode in the rectifier is...
Hi Friends, Can we save energy cost and measure it by improving power factor? I know if my billing is in KVAH and not in KWH, I have to pay...
​ We figure the design just to the left of the touchpad is more than enough to convince you to impulse-buy the $750 HP Pavilion dv2, but just in case...
Name:keeping trying *Engineering Trade: process and industrial Location: Oman *Occupation: (Student in level one Work Experience: - *Hobbies & Interests: reading and writting stories *Aim in life: be at the...
Hi to all you geeks out there... Is there anything such as an ideal geeks computer or a laptop... keep me posted ;-)