bharatwalia
Joined: 04 May 2009 Posts: 35 Location: India
|
| buzzer routine |
Posted: Sun Jan 09, 2011 2:27 am |
|
|
Hey guys below is my buzzer routine.
I wrote this routine to set "PIN_B1" high every 2 seconds for 300ms
and then set it low again.
But the problem here is that the pattern is not synchronized, the "ON" time keeps on decreasing and again gets normal.
| Code: |
//-------------------------------------------------------------------------------------
#INT_TIMER1
void Timer1(void)
{
set_timer1(TMR1RESET);
ticker_2++;
ticker_buzzer++;
if(ticker_2>100){
ticker_2=0;
buzzer_time++; --------->counting seconds.
}
if(ticker_buzzer>10){
ticker_buzzer=0;
buzzer_time_on++; ------------------>counting 100ms
}
}
//-------------------------------------------------------------------------------------
void buzzer(void)
{
if(inv_on){
if(buzzer_time==2){ -------->2 seconds
buzzer_time=0;
output_high(PIN_B1);
}
if(buzzer_time_on==3){ ----------------->300ms
buzzer_time_on=0;
output_low(PIN_B1);
}
}
}
//-------------------------------------------------------------------------------------
|
Thanks. |
|