kolopipo
Newbie level 4
PWM PIC16F877 problem.
Hi all,
I am generating a PWM using PIC16F877. I had been trying out example code in CCS compiler for setting up PWM. When doing simulation using Proteus Isis, I cant see any PWM pulse from pin C2. Please help. Is it the frequency problem? Or the header file got problem? I still cant get any pulse even though had tried many value of duty cycle. Can't even get high signal from it.Below is my code. It is very simple program to just generate PWM. I am using 20Mhz crystal in proteus simulation.
Hi all,
I am generating a PWM using PIC16F877. I had been trying out example code in CCS compiler for setting up PWM. When doing simulation using Proteus Isis, I cant see any PWM pulse from pin C2. Please help. Is it the frequency problem? Or the header file got problem? I still cant get any pulse even though had tried many value of duty cycle. Can't even get high signal from it.Below is my code. It is very simple program to just generate PWM. I am using 20Mhz crystal in proteus simulation.
Code:
#include <16F877.h>
#device adc=8
#use delay(clock=20000000)
#fuses NOWDT,RC, NOPUT, NOPROTECT, BROWNOUT, LVP, NOCPD, NOWRT, NODEBUG
//////////Main Function//////////
void main ()
{
int16 duty_time;
set_tris_C(0b00000000);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_1,249,1);
setup_CCP1(CCP_PWM);
while (1){
set_pwm2_duty(125;
}
}