Quote Originally Posted by jmgelba View Post
Ok, I think I understand all except how did you fill in bits 4 and 5? Why a 0 and 1 in the location you put them in?
assuming a 10 bits results as follow
Code:
'Bit number 9876543210
   MyVar = %1111110011
In red the MSB, in Blue the LSBs for PWM.

Shift them all two position to the right you have
Code:
   MyVar = %0011111100
Now, where are the LSB now... gone... you need to extract them 2 from the original 10bit value, so Bit0 and BIT1, and transfer them to Bit4 and BIT5 of CCP1CON register
CCP1CON.4=MyVar.0 ' bit0 to bit4 of CCP1CON
CCP1CON.5=Myvar.1