rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Wed Sep 29, 2004 9:23 am |
|
|
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?
Ronald |
|