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] PIC 16F877A PWM Implementation Help Required

Status
Not open for further replies.

asking

Full Member level 5
Full Member level 5
Joined
Sep 21, 2010
Messages
279
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,298
Activity points
3,377
Hello,

I have been confused about using the PWM in PIC16F877A, I have used PWM in 16F628A, it seems to be much easier while using with mikroc but in PIC16F877A when i tried to compile code it says...PWM1_Init(5000); is not valid parameter...or something like that error...

I read the Datasheet of PIC16F877A, but m not clear about it.... Which other Registers need to be set...before Initializing PWM1 and PWM2... could anyone brief me ? please...
 

Make sure PWM library is selected in library manager.

This code works for me:

Code:
// very simple PWM test

void main()
{
    PWM1_Init(5000);
    PWM1_Set_Duty(30);
    PWM1_Start();

    while(1);           // loop forever
}
 
  • Like
Reactions: asking

    asking

    Points: 2
    Helpful Answer Positive Rating
ok i got it...

library function should be called in this order only else it will give error

PWM1_Init
PWM1_Set_Duty
PWM1_Start
PWM1_Stop

so actually i was starting before setting the Duty cycle so... :p
 

ok i got it...

library function should be called in this order only else it will give error

PWM1_Init
PWM1_Set_Duty
PWM1_Start
PWM1_Stop

so actually i was starting before setting the Duty cycle so... :p

It should be okay to start the PWM before setting the duty cycle. That shouldn't be the problem. The initialization statement just needs to be at the beginning.
 
  • Like
Reactions: asking

    asking

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top