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 support@ccsinfo.com

Does get_timer1() conflict with Timer1 Interrupt

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








Does get_timer1() conflict with Timer1 Interrupt
PostPosted: Thu Mar 05, 2009 9:59 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 05, 2009 10:05 pm     Reply with quote

What happened to putting Timer1 questions all in one thread, rather than
a bunch of scattered posts ?
boulder



Joined: 15 Mar 2008
Posts: 53

View user's profile Send private message

PostPosted: Thu Mar 05, 2009 10:16 pm     Reply with quote

Since my questions are different about Timer1, I do not want to confuse people. I am sorry about this.
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