![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
The 16f877a has a timer that supports both postscalar and prescalar operations.
Could anyone please let me know the difference between the prescalar and postscalar functionality? I tried using the prescalar functionality in the pic 16f877a and realized depending upon the number set as prescalar, that many instruction cycles would have to pass by before the timer increments by one. But I don't understand the concept of postscalar. Thank you
__________________
A scientist trys to see the world the way it is An enginneer trys to see a world that has never been |
|
|
|
|
|
|
(permalink) |
|
Hi desijays I'm also in the same situation like you worked with pre-scaller but don't know what is post-scaller & for what purpose is there.
I'm also waiting for a good reply. |
|
|
|
|
|
|
(permalink) |
|
It's dead simple, and explained in the datasheets and reference manuals.
A timer is a clock oscillator feeding a counter - a pre-scaler goes between the clock and counter, a post-scaler goes after the counter. There are specific advantages for either. |
|
|
|
|
|
|
(permalink) |
|
Nigle beat me to it:
---------------------------- The prescaler divides down the clock going into the counter register. A postscaler of 1:1 is like a counter witout a postscaler. With the postscaler 2:1 the counter must reach zero twice for the timer interupt flag bit to be set With the postscaler 4:1 ... 4 times .... etc
__________________
search engine for electronic partsJunebug USB PIC programmer kit., USB Bit Wacker, Homepage The 15 Minute Printed Circuit Board! (+drill time) Last edited by 3v0; 16th April 2008 at 09:51 AM. |
|
|
|
|
|
|
(permalink) |
|
Hi thanks for the reply now we know where the pre & post scallers are.
If pre-scaller is set to 1:4 & post-scaller 1:2 same as directly load pre-scaler 1:8 without a postscaler 1:1 Thanks |
|
|
|
|
|
|
(permalink) |
|
Thank you Nigel and 3vo. I now get an idea of the difference between the postscalar and prescalar. But I'll have to work it out on the controller for real, before I am convinced I figured it out.
Thank you agian.
__________________
A scientist trys to see the world the way it is An enginneer trys to see a world that has never been |
|
|
|
|
|
|
(permalink) | |
|
Quote:
__________________
search engine for electronic partsJunebug USB PIC programmer kit., USB Bit Wacker, Homepage The 15 Minute Printed Circuit Board! (+drill time) |
||
|
|
|
|
|
(permalink) |
|
One advantage of having the postscaler set to more than 1:1 is when you use PWM. This would allow you to run the PWM rate at say 40Khz but you could set the postscaler to 1:40 so that the interrupt routine to update the PWM duty cycle only occurs at a 1Khz rate thus making it easy to output a low frequency sinewave using only one timer.
__________________
--- The days of the digital watch are numbered. --- |
|
|
|
|
|
|
(permalink) |
|
Thank you everyone for all the replies. So this is what I tried and this is what I observed.
I used the pic16f877a microcontroller. I used timer 2. First I set the prescaler to 1:4 and as anticipated for every 4 instruction cycles the timer2 counter incremented by one. Then I reset the prescalar to 1:1 and set the postscalar 1:2 and the timer 2 counter had to topple from '0xff' to '0x00' twice before the timer2 flag bit was set. I hope my observations conform to the norm. Tonight I plan to set the prescalar and the postscalar to jus see how it works. Thank you.
__________________
A scientist trys to see the world the way it is An enginneer trys to see a world that has never been |
|
|
|
|
|
|
(permalink) | |
|
Quote:
|
||
|
|
|