|
|
View previous topic :: View next topic |
Author |
Message |
evsource
Joined: 21 Nov 2006 Posts: 129
|
setup_timer2 PWM postscale not working |
Posted: Wed Feb 07, 2007 5:15 pm |
|
|
With the setup_timer2 function for setting up PWM, I can't get the postscale to change anything:
Code: | setup_timer_2(T2_DIV_BY_1,64,1); |
If I change the last parameter (the postscale) to anything other than 1, it doesn't change the frequency at all.
Is this a bug? Can someone confirm that they've got it to work? I'm using a 16F876A. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Feb 07, 2007 5:31 pm |
|
|
Read this note from the 16F876A data sheet, in the PWM section:
Quote: |
Note:
The Timer2 postscaler (see Section 7.1) is
not used in the determination of the PWM
frequency. The postscaler could be used
to have a servo update rate at a different
frequency than the PWM output.
|
In other words, if you want to periodically change the PWM duty cycle,
you could do it inside a Timer2 interrupt routine. This would allow the
duty cycle to be changed after an integral number of PWM cycles.
The Timer2 postscaler allows you to control the rate at which Timer2
interrupts occur. Instead of occuring once every PWM cycle, you
could set the interrupt to occur once every 8 cycles (for example).
The reason for doing this is described in the Microchip patent on the
PWM module:
Quote: |
According to the present invention, a scheme is provided by which
interrupts are generated in connection with the PWM function of the
microcontroller only at relatively long intervals, while still permitting
the PWM to be run at considerably higher frequencies. This is achieved
by use of a postscaler circuit in conjunction with a PWM timing module.
The postscaler functions to reduce the interrupt overhead by reducing
the frequency of interruption of the CPU, without affecting the
setting of the period of the waveform.
|
This text is from the patent at the following link. Scroll down about 2/3 of
the way down the page, to the section on "Summary of the Invention":
http://www.freepatentsonline.com/5594894.html |
|
|
|
|
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
|