PWM 18f2550

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#INCLUDE <18F2550.

h>
#use delay(clock=4000000)
#fuses XT,PUT,NOPROTECT,BROWNOUT,NOLVP,NOWDT
#use standard_io(A)
#use standard_io(B)
#use standard_io(c)
int16 i;
void main()
{
setup_timer_2(T1_DIV_BY_1,224,1);
setup_ccp1(CCP_PWM);
for(i=0;i<1024;i++)
{
set_pwm1_duty(i);
delay_ms(1);
if(i>=1023)
{
for(i=1024;i>0;i--)
{
set_pwm1_duty(i);
delay_ms(1);
if(800>=i){
set_pwm1_duty(800);
}
}
}
}
}

You might also like