Pwm-16f877a-frequence-controlling

General discussion on mikroC.
Post Reply
Author
Message
Ali13
Posts: 1
Joined: 12 May 2012 17:45

Pwm-16f877a-frequence-controlling

#1 Post by Ali13 » 12 May 2012 18:05

hi everyone,

iam doing a project on pic 16f877a iam almost done with it just one problem left and that is that i cant increment or decrement my Frequence i know how to set up my Frq lvl an that is

PWM1_init();

so i can set my freq but i want to do incrment or decrement in it with two push buttons like iam changing the Duty here just shown blow

if(RD0_Bit) {
if(duty<=255) {
Delay_ms(10);
Work++;
PWM1_Set_Duty(duty);
}
}
if(RD1_Bit) {
if(duty>=1) {
Delay_ms(10);
Work--;
PWM1_Set_Duty(duty);
}
}


ya just like iam changing the duty i wana change the Frequence

hexreader
Posts: 1782
Joined: 27 Jun 2010 12:07
Location: England

Re: Pwm-16f877a-frequence-controlling

#2 Post by hexreader » 14 May 2012 07:31

Check out the PWM section of your datasheet.

Register PR2 sets the period (and thus frequency) of PWM outputs.

Put numbers (unsigned char) from 0 to 255 into the PR2 register to change frequency while PWM is running.
Start every day with a smile...... (get it over with) :)

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Pwm-16f877a-frequence-controlling

#3 Post by filip » 14 May 2012 10:38

Hi,

Also, please check the PWM example in the Examples folder of the compiler.

Regards,
Filip.

mahmoud1230
Posts: 3
Joined: 15 Mar 2013 21:48

Re: Pwm-16f877a-frequence-controlling

#4 Post by mahmoud1230 » 17 Mar 2013 20:38

This example does not work to making increment or decrement,Thanks

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Pwm-16f877a-frequence-controlling

#5 Post by filip » 18 Mar 2013 15:57

Hi,

I believe I have answered you here :
http://www.mikroe.com/forum/viewtopic.p ... 56#p209356

Regards,
Filip.

Post Reply

Return to “mikroC General”