Page 1 of 1

Pwm-16f877a-frequence-controlling

Posted: 12 May 2012 18:05
by Ali13
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

Re: Pwm-16f877a-frequence-controlling

Posted: 14 May 2012 07:31
by hexreader
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.

Re: Pwm-16f877a-frequence-controlling

Posted: 14 May 2012 10:38
by filip
Hi,

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

Regards,
Filip.

Re: Pwm-16f877a-frequence-controlling

Posted: 17 Mar 2013 20:38
by mahmoud1230
This example does not work to making increment or decrement,Thanks

Re: Pwm-16f877a-frequence-controlling

Posted: 18 Mar 2013 15:57
by filip
Hi,

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

Regards,
Filip.