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

Timer1 Overflow

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







Timer1 Overflow
PostPosted: Thu May 18, 2006 4:10 pm     Reply with quote

Hi how can i check for timer 1 overflow?

This is how i did it on a PIC 18F using the microchip 18 compiler:


Code:


if(PIR1bits.TMR1IF) //If timer 1 has overflowed add 65536
  {
   PIR1bits.TMR1IF = 0;
   comp_count += 65536;
  }




IM now trying to do the same on a PIC 16f8777a using the CCS compiler

I realize i can do this by using the timer overflow interrupt but is there a way of directly accesing this varible like above?

Thanks

Pilt
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Thu May 18, 2006 4:18 pm     Reply with quote

Sure - just use a #bit declaration. You need to look in that PIC's datasheet for the exact location of that flag. I did the same thing for a 18F4680, and this is how I did it:

Code:
#bit tmr1_int_flag = 0xf9e.0


For the 18F4680, it is bit 0 of memory location 0xF9E. The location of the timer 1 interrupt flag will be different for your processor.

Your code would then be like this:

Code:
if(tmr1_int_flag) //If timer 1 has overflowed add 65536
  {
   tmr1_int_flag = 0;
   comp_count += 65536;
  }
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu May 18, 2006 4:19 pm     Reply with quote

Quote:
but is there a way of directly accesing this varible like above?

This thread gives examples of how to declare TMR1IF as a bit variable:
http://www.ccsinfo.com/forum/viewtopic.php?t=17174&highlight=tmr1if
pilt1
Guest







PostPosted: Thu May 18, 2006 6:42 pm     Reply with quote

Thanks, thats just what i needed!

Cheers

Pilt
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