
#include <REG52.H>
#include <generic1.h>
sbit YELLOW = P3^6;
sbit GREEN = P3^7;
bit hit_ = 0;
/*=============================================================================
/*-----------------------------------------------------------------------------
When the Edge trigger is recieved 'hit' is set and the control returns to the main function 
-----------------------------------------------------------------------------*/
void ex0_isr (void) interrupt 0
{
	hit_ = 1;
}

/*=============================================================================
==============================================================================*/
void main (void)
{
/*-----------------------------------------------
Configure INT0 (external interrupt 0) to generate
an interrupt on the falling-edge of /INT0 (P3.2).
Enable the EX0 interrupt and then enable the
global interrupt flag.
------------------------------------------------------------------------------*/
IT0 = 1;   // Configure interrupt 0 for falling edge on /INT0 (P3.2)
EX0 = 1;   // Enable EX0 Interrupt
EA = 1;    // Enable Global Interrupt Flag
/*------------------------------------------------------------------------------
The control remains outy of the main function na d as soon as 'hit is set the
LED is switched on for 9 mili-seconds and then switched off

Now as there is an edge trigger every 0.01 seconds, thus the led glows for 
9 mili-second  then switches off for 1 mili-second and then again glo ws for
9 mili-second and so on infinitely untill the trigger is presnt at the P3.2    
------------------------------------------------------------------------------*/
	while(1)
	{
	if(hit_ ==1)
		{
		YELLOW = 0;
		GREEN = 0;
		msec_wait(9);
		YELLOW = 1;
		GREEN = 1;
		hit_ = 0;
		}
	}
}
/*=============================================================================
=============================================================================*/
