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.

PIC 16f877 pwm

Status
Not open for further replies.

sundas

Newbie level 1
Joined
Aug 29, 2010
Messages
0
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,280
Activity points
1,280
hello, i need a c code help for pwm with generating variable duty cycles from 0 t0 100%
using pic 16f877 HITECH compiler
at the moment i've generated pulse of 100%, 50% manually but i want to do it as a loop or variable duty cycles...
thanx
regards
 

no reply..............
 

Dear friend i really want 2 help u but i never have worked on PWM, although i have basic concepts about it. can u tell me how u have implemented 100% and 50% duty cycle. May be then i can help u.
 

#include<pic.h>

void main()
{
TRISC=0x00;
CCP1CON=0x0C;
PR2=0xFF; // set PWM period for approximately 19.53KHz
CCPR1L=0xFF; // set PWM duty cycle to 50%
T2CON=0x04;
}
 

#include <htc.h>
#include <pic.h>

void main ()
{
int a=0xFF;
TRISC=0x00;
CCP1CON=0x0C;
PR2=0xFF; // set PWM period for approximately 19.53KHz
for(CCPR1L=0xFF,CCPR1H=0xFF;CCPR1L>0x00,CCPR1H>0x00;CCPR1L--,CCPR1H--)
_delay(100000);
T2CON=0x04;
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top