Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

setting duty cycles using ccp1con

Not open for further replies.


Junior Member level 2
Nov 3, 2010
Reaction score
Trophy points
Activity points
How do I set the pwm module to use the 8 msbs of the ccp1rl bits and ignore the 2lsbs in ccp1con

In other words you want to take a 10-bit PWM duty cycle and turn it into an 8-bit PWM duty cycle?


My program is varying duty cycles taking them from a lookup tgable therefore it is difficult to change ccp1rl at the same time changing ccp1con and the signal is at 200khz therefore the resolution is to be about 6 bits so how do I set these in my program.

One possibility is leaving the LSBs in CCP1CON set to zero, while changing only the eight MSBs in CCP1RL this would effectively reduce your PWM duty cycle resolution by a factor of 4.

This means your changes to the PWM duty cycle will by coarser, larger changes.

---------- Post added at 09:00 ---------- Previous post was at 08:51 ----------

Here's a thread discussing modification of PWM duty cycle:

PWM Duty Cycle
  • Like
Reactions: gedza


    Points: 2
    Helpful Answer Positive Rating
CAN YOU PLEASE HELP ME ON SINUSOIDAL PWM .Is the value of ccpr1l loaded by an interrupt service routine of tmr2 or there is need to use another timer . I want to get a 50hz sine wave therefore should I use tmr2 to change the duty am I going to determine the 50Hz frequency in my code most preferebly in asm.My switching frequency is 200khz .

Hi gedzak,

I'm working on a ASM program using interrupts to generate PWM.

Actually, I found some code from a previous project using PWM sinusoidal generation, so I modifying it to fit your needs. I'll also physically test the algorithm.

Quick question, by "...switching frequency is 200kHz", you mean the sampling frequency of PWM, correct?

Yes it is the frequencyis the sampling frequency.thanks

Not open for further replies.

Part and Inventory Search

Welcome to