The only problem I can see is that you are assuming the other bits in the CCP1CON are always set correctly? For the sacrifice of a few extra instructions I would prefer to have ALL register bits set as in: CCP1CON=$0C|((pwm_pars&$3)<<4)