CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

buzzer routine

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
bharatwalia



Joined: 04 May 2009
Posts: 35
Location: India

View user's profile Send private message

buzzer routine
PostPosted: Sun Jan 09, 2011 2:27 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group