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

How to use timer2 to blinking led7 whenever push a button

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



Joined: 06 Sep 2007
Posts: 4

View user's profile Send private message

How to use timer2 to blinking led7 whenever push a button
PostPosted: Sat Sep 29, 2007 2:09 am     Reply with quote

Question
Hi all!
I'm using 16F877A. I write a program to blink led7 when push a button . I use timer2 with set up:
void Init_Timer(void)
{
setup_timer_2(T2_DIV_BY_4, 250, 1);
enable_interrupts(GLOBAL);
enable_interrupts(INT_TIMER2);
}
and isr as the following:
void timer2_isr(void)
{
Flag=~Flag;
}
and in scan routine I write:
Switch (ModeValue)
{
case 1:
{
clear_interrupt(INT_Timer2);
output_high(PIN_E0);
SetHour();
ds1307_set_date_time(day,mth,yr,dow,hr,min,sec);

Init_Timer();
if(Flag==true)
{
if(level==0) level=1;

}

break;
}
Progam runs, led blinking. but sometime led7 don't lighten when I push button. Please help me how to drive a interrupt, stop it whenever I want. Thanks!!
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sat Sep 29, 2007 2:47 pm     Reply with quote

In this forum it is not necessary to be a member to post a question related to CCS
C Compiler oriented to PIC MCU´s, also it is not mandatory to login, but to start a new
thread we expect you follows some basic rules.
Nobody likes to read C code in the way you posted, this one can be one of the reasons
why nobody answered you.

You will find some guide here:
http://www.ccsinfo.com/forum/viewtopic.php?t=26245
http://www.ccsinfo.com/forum/viewtopic.php?t=29483

Then post your question accordingly.


Humberto
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