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.

How set PWM for PIC 16F877A

Status
Not open for further replies.

Rooney_04

Member level 2
Joined
Oct 2, 2010
Messages
42
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,577
hi
how i could set this PWM for 20MHz in the PIC 16F877A? if i could get the source code should be better since i m new to PIC programming
 

Here you go: But this is varying pwm. Modify the for loop accordingly.

#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;
}
 

By the way you could get better programs while you google @ net.Try to learn the programming & try to do it of your own.
Regards,
Jerin.
 

If i could program that with the given code. Could i test it to the Proteus to see the graph?
 

Here is a code for PWM in assembly language done in MPLAB compiler.
Regards,
Jerin.
 

Attachments

  • New Text Document.txt
    389 bytes · Views: 102

hi thanks..
but the compiler i using is PIC C compiler. so the MPLAB source code you(incomplete_jerin) given me can be used in this compiler huh?
 

for incomplete_jerin code, you only need MPLAB because it is already in ASM

---------- Post added at 13:38 ---------- Previous post was at 13:36 ----------

yup, using oscilloscope. I tested it with proteus sim =)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top