Home › Forums › Microcontrollers › PIC Microcontroller › PWM by pic 16F877A › Reply To: PWM by pic 16F877A
March 1, 2015 at 11:53 pm
#10953
sandeep
Participant
Hi Ligo,
As i also have problem on pwm, so i thought posting my doubt over here is fine.but i work on mplab.
I just tried to run a pwm with the duty cyle of 78% of the period, but it is not working on proteous, suggestions pls.
void main() { PR2=0xFF;//setting period=0.0002048 CCP1CON=0b00001100;//setting to pwm mode<3:0> and duty value<5:4> CCPR1L=0xC8; //setting value of 800 to make duty=0.00016,which //is 78% of period. //T2CON=0b00000001;//prescale<1:0> of1:4 T2CKPS0=1; T2CKPS1=0; TMR2ON=1; //timer2 is on i.e clock pulses are provided. }