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.

[SOLVED] Problem in the code to generate PWM using PIC 16F877A

Status
Not open for further replies.

Akhil Mohan

Member level 2
Joined
May 13, 2011
Messages
53
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,731
Hello,
Please go through the code to generate a pulse of 10% duty cycle and 250Hz ( for CCS C compiler)
#include <16F877A.h>
#fuses XT,NOWDT,NOPROTECT,NOLVP,BROWNOUT,PUT
#use delay(clock=4000000)// 4MHz

main()
(
output_low(PIN_C2); // Set CCP1 output low

setup_ccp1(CCP_PWM); // Configure CCP1 as a PWM

setup_timer_2(T2_DIV_BY_16,249, 1); // 250 Hz

set_pwm1_duty(25); // 10% duty cycle on pin C2

while(1);
}

Thanks in advance,
Akhil
 
Last edited:

I sorted out the error, i have inserted round brackets instead of curly :)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top