Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PWM geeneration with PIC16F877 problem.

Status
Not open for further replies.

kolopipo

Newbie level 4
Joined
Sep 27, 2009
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,322
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.
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;
 }
}
 

Re: PWM PIC16F877 problem.

the program is Ok. I thing probleme is on Proteus
 

Re: PWM PIC16F877 problem.

set_pwm2_duty(125;

set_pwm2_duty(125);
 

just put th command while on the begining:

Code:
#include <16F877a.h>
#device adc=8
#use delay(clock=20000000)
#fuses NOWDT,RC, NOPUT, NOPROTECT, BROWNOUT, LVP, NOCPD, NOWRT, NODEBUG

//////////Main Function//////////
void main ()
{
while (1)
{
   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);


   set_pwm2_duty(125);
 }
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top