Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC16f877A pwm doubt

Status
Not open for further replies.

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...
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top