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

timer2

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







timer2
PostPosted: Wed Jul 04, 2007 8:17 am     Reply with quote

timer2 for one second exact
Ttelmah
Guest







PostPosted: Wed Jul 04, 2007 8:26 am     Reply with quote

Depends on your crystal frequency...
Probably not possible. More likely to have to have something like 10mSec exactly, and count to 100.

Best Wishes
Guest








PostPosted: Wed Jul 04, 2007 8:30 am     Reply with quote

Ttelmah wrote:
Depends on your crystal frequency...
Probably not possible. More likely to have to have something like 10mSec exactly, and count to 100.

Best Wishes



the crystal frequency is 20mhz
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Thu Jul 05, 2007 9:37 am     Reply with quote

With a 20MHZ crystal, try:

setup_timer_2(T2_DIV_BY_16,249,10);

This will cause the timer interrupt to happen 125 times a second. Simply have a variable count to 125 and set a flag. Then, have this flag addressed in your main() somewhere. Don't forget to reset your counter variable to zero when it sets the flag or it will set the flag every time the ISR is entered after that.

Try looking at the spec. sheet for the PIC you are using and look at the section on timer2. It helps to see how the hardware is configured and then understand how the compiler is setting things up.

Ronald
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