PIC16f877A pwm doubt

rparthiban69

New Member
i need to vary pwm 0 to 255 by using com port. PR2=0x3F: // 8bit resolution

//CCPxCON calculation
Value=ucdata;
Value=Value<<4;
CCP8CON= 0b00001100 | Value;

//CCPRxL calculation
data=ucdata/4; // changing 128 bit resolution
CCPR8L=data;

this calculation is changing PWM only vary 0 to 128 only.

how to vary the pwm (0 to 255) by using this calculation?
 
You just load the CCPRxL register with the 6 MSbits the 2 LSbits go in the CCPxCON ( bits 4 and 5)... Therein 8 bit resolution..

You can't load CCPRxL with a number above 0x3F ( the PR2 register) as there will be no output...
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…