|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
Does get_timer1() conflict with Timer1 Interrupt |
Posted: Thu Mar 05, 2009 9:59 pm |
|
|
Hi,
I found out that my processor has two timers, TIMER0 and TIMER1, but I can use only Timer1 since TOCKI is used for GPIO function.
So can I disable INT_TIMER1 before it needs to check timeout wtih set_timer1(0) and get_timer1() and enable INT_TIMER1 back after checking timeout event is finished?
Code: |
#include <16F689.h>
#include <stdio.h>
#include <stdlib.h>
#use delay(clock=3686400, crystal)
#use rs232(baud=115200, xmit=PIN_B7, rcv=PIN_B5)
#fuses XT, NOWDT, PUT, MCLR, NOPROTECT, NOCPD, NOBROWNOUT, NOIESO, NOFCMEN
unsigned int16 x;
#INT_TIMER1
void timer1_isr(void)
{
set_timer1(0x1F00); //500ms
EVENT_1();
}
void main()
{
setup_timer_1( T1_INTERNAL | T1_DIV_BY_8);
enable_interrupts(INT_TIMER1);
enable_interrupts(global);
while(1)
{
disable_interrupts(INT_TIMER1);
set_timer1(0);
EVENT_2();
x = get_timer1();
enable_interrupts(INT_TIMER1);
}
}
|
Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Mar 05, 2009 10:05 pm |
|
|
What happened to putting Timer1 questions all in one thread, rather than
a bunch of scattered posts ? |
|
|
boulder
Joined: 15 Mar 2008 Posts: 53
|
|
Posted: Thu Mar 05, 2009 10:16 pm |
|
|
Since my questions are different about Timer1, I do not want to confuse people. I am sorry about this. |
|
|
|
|
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
|