PIC Microcontoller IO Routines

Pulse Width Modulation

Bob Bullock of Western Support Group Ltd. says:

In my previous post I mentioned the formula in the manual to calculate the maximum PWM resolution (in bits) for a given PWM frequency appeared to be accurate only for a prescaler setting of 1:1. I did confirm this. These three combinations of PR2 and prescaler settings all have the same PWM frequency, but require a different value for CCPR1L for a 50% duty cycle and therefore have different max PWM resolutions.
PR2            prescaler             CCPR1L        duty cycle
255               1:1                 128             50%
64                1:4                  32             50%
16                1:16                  8             50%

The corrected formula that takes into account the prescaler setting should be:

bits resolution = LOG(Fosc / (Fpwm * (Timer2 prescaler value))) / LOG(2)

the lowest 2 bits are the two bits in CCP1CON

Dan Michaels from Oricom says:

          ------- PWM ---------
xtal       10-bit      8-bit
20 Mhz    19.53 Khz    78.12 Khz
10         9.7         39.06
 8         7.8         31.2
 5         4.9         19.53
 4         3.9         15.6

See also: http://www.piclist.com/postbot.asp?by=time&id=piclist/2000/08/07/143402a

Questions: