EEVblog Electronics Community Forum
Electronics => Beginners => Topic started by: Simon on January 12, 2010, 08:22:49 pm
-
what sort of relationship is there between the clock speed and the maximum PWM frequency of a pic ? (12F615 / 16F88 in my case) and not only the maximum PWM frequenct but resolution and frequency versus clock speed ?
-
The PIC timer counts Fosc/4 rate (or lower with prescaler), so with 4 MHz clock, the timer clock frequency is 1 MHz.
PWM frequency is same than timer rollover-rate, which in turn is timer clock/(counts per rollover), so if you have 1 MHz timer clock and timer has 256 counts (8 bits resolution), the PWM frequency will be ~3.9 kHz.
Regards,
Janne
-
aha right I though it was something like that I just didn't realise that there was the 4X prescaler, so if I was going to sacrifice resolution say make it 7 bits I could run at a frequency of 7.2 KHz ? (given the 4 MHz clock and /4 prescaler)
-
4 MHz was only an example. 16F88 runs up to 20 MHz, so maximum timer clock is 5 MHz. That gives you 19.5 kHz PWM frequency @ 8 bits resolution.
Regards,
Janne
-
Yes I see, what I'm saying is can I sacrifice resolution for frequency ? if it comes down to counts can I say a clock speed of 4 MHz 1 MHz counter 3.9 KHz frequency @ 8 bits, or 7.2 KHz @ 7 bits ?
-
Certainly you can make trade-offs between resolution and frequency. PIC16F88 datasheet (http://ww1.microchip.com/downloads/en/devicedoc/30487c.pdf#page=87) table 9-3 @ page 87 lists some combinations @ 20 MHz. Resolution does not need to be integer number of bits, for example setting PR2 to 99 yields resolution of log2(99) ~= 6.64 bits.
Regards,
Janne