Hi Shivaram, Thanks for your reply. pls have a look at the following code
/******************************* Fuse Settings ******************************/
#fuses INTRC_IO,NOWDT,NOPUT,NOMCLR,BROWNOUT,PROTECT,NOCPD
/***************** Based on Internal Clock frequency of 4MHz ****************/
#use delay(clock=4000000)
/****************************************************************************
Timer0 Interrupt Service Routine to Generate Blinking.
----------------------------------------------------------------------------
Blinking Rate -------------------------------------- 40/min
Blinking Frequency --------------------------------- 0.667 Hz
Time period ---------------------------------------- 1.5s
Blinking Duty Cycle -------------------------------- 50%
********************* Interupt Service Routine ******************************/
#INT_TIMER0
void Flashing_Timer()
{
set_timer0(42); // Timer preset to produce
// 250uS interrupt cycle.
Blink++; // increment Blink Time Counter
mSec++; // Increment Millisecond Counter
if(Stop_Seconds == 0)
{
if (mSec == 4003) // Second Counter
{
Seconds++; // Increment seconds count
mSec =0; // Reset mSec for next second
}
}
if(Stop_Blink == 0)
{
if (Blink == 3007) // Flashing timer to provide
// 40 Flashes/min
{
output_toggle(Left); // Toggle both lamps
output_toggle(Right);
Blink =0; // Reset flahing counter
}
}
}
/******************** Interupt Service Routine End ***************************/
/**************************** Main Function **********************************/
void main()
{
Initialize(); // Initialization Routine
Calibrate_Internal_Oscillator(); // Internal Oscillator
// Calibration Routine
Timer_Set();
delay_ms(100);
/**************************** Perpetual Loop *********************************/
while(1) // Do forever
{
while (input(Start) ) // Wait for start signal - mag switch
{
stop_seconds = 1; // Seconds count disabled
output_low(left); // Set lamps off
output_low(right);
seconds = 0; // Ensure seconds start at 0
}
while (!input (Start)) // Activate TAFLU
{
delay_ms(5);
if (!input (start));
{
//Switch_set(); // Get Delay time
output_high (Left); // Set one Lamp on
output_low (right);
stop_seconds = 0; // Enable seconds count
enable_interrupts(INT_TIMER0); // Start Timer0
enable_interrupts(GLOBAL); // enable interupts
Stop_Blink = 0;
/*****************************************************************************/
// Loop here until Seconds = minutes or switch is pressed
/*****************************************************************************/
do
{
Delay_Ms(1000); // Make sure Switch released
if (!input (Start)) // See if switch Activated
Seconds = Minutes; // Set seconds = minutes
} // to stop flash
while (seconds < minutes); // until the seconds = mins
}
}
/************************* Time expired **************************************/
{
stop_seconds = 1; // stop the seconds
stop_Blink = 1; // stop the flasher toggle
disable_interrupts(INT_TIMER0); // Disable timer interupt
disable_interrupts(GLOBAL); // Disable global interupt
output_low(left); // Turn lamps off
output_low(right);
}
Delay_Ms(1000);
/***************************** End of main loop ******************************/
}
/**************************** Main Function End ******************************/
}
/*****************************************************************************/
I could not understand the values in it "if (mSec == 4003) " & "if (Blink == 3007)" where did they drive these values(4003 and 3007) from?