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

A detailed tutorial on prescalers

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







A detailed tutorial on prescalers
PostPosted: Wed Sep 29, 2004 8:39 am     Reply with quote

Hi,

I still cannot understand pre-scalers, can anyone tell me in detail how they work and how to set a desired value ???

thank you
arun
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Wed Sep 29, 2004 9:23 am     Reply with quote

Let's say that you have a timer running and it counts up to 255(8 bits) and then turns over to 0(zero) again (a total of 256 counts). Here is a table that will show you what you will get out:

1:1 - 256 counts go in, 256 counts come out
1:2 - 256 counts go in, 128 counts come out
1:4 - 256 counts go in, 64 counts come out
and so forth.

A pre-scaler simply divides whatever is coming in by the factor that you set it to. There are pre-scalers and also post-scalers. If you have a crystal running at, say, 20MHZ. That frequency is divided by 4 before it reaches the timer/counter sections. So, we have an effective frequency of 5MHZ at the input of the timer. Now, if you have your prescaler set to 1:1 then the timer will be running at 5MHZ as well. If your prescaler is set to 1:4 then the timer will be running at 1.25MHZ. The pre- and post-scalers make it so you can adjust how often the timer/counter will generate an interrupt. If the interrupt happens to often then the PIC won't have enough time to execute anything else that you may have in the body of the code.

Clear as mud? Wink

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