please dont rip this site

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:


file: /Techref/microchip/pwmrescalc.htm, 2KB, , updated: 2006/9/21 16:00, local time: 2024/7/14 04:05,

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF=""> How much PWM resolution can be achived given a prescaler setting and clock speed in a PIC cpu.</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?


Welcome to!


Welcome to!