|
|
View previous topic :: View next topic |
Author |
Message |
phithuc
Joined: 06 Sep 2007 Posts: 4
|
How to use timer2 to blinking led7 whenever push a button |
Posted: Sat Sep 29, 2007 2:09 am |
|
|
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
|
|
Posted: Sat Sep 29, 2007 2:47 pm |
|
|
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 |
|
|
|
|
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
|