void interrupt()
{
os_cnt++;
while(os_cnt<=5+feedback)
{
RC6_bit = 0;
RC7_bit = 0;
break;
}
while(os_cnt>=5+feedback && os_cnt<=85-feedback)
{
RC6_bit = 1;
RC7_bit = 0;
break;
}
while(os_cnt>=85-feedback && os_cnt<=90+feedback)
{
RC6_bit = 0;
RC7_bit = 0;
break;
}
while(os_cnt>=90+feedback && os_cnt<=160-feedback)
{
RC6_bit = 0;
RC7_bit = 1;
break;
}
while(os_cnt>=160-feedback)
{
RC6_bit = 0;
RC7_bit = 0;
break;
}
while(os_cnt==161)
{
os_cnt=0;
break;
}
TMR0 = 200; // Timer TMR0 is returned its initial value
INTCON = 0x20; // Bit T0IE is set, bit T0IF is cleared
}
////////////////////
///////////////////
void main()
{
..................
............
while(1)
{
ADCON0=0b00000001;
adc_rd0 = ADC_Read(0);
avg_pwm = adc_rd0;
while(avg_pwm>80)
{
if(feedback<50)
{
feedback++;
//Delay_ms(20);
}
else
{
feedback = feedback;
}
break;
}
while(avg_pwm<=80)
{
if(feedback>1)
{
feedback--;
//Delay_ms(20);
}
else
{
feedback = feedback;
}
break;
}
}
}