So i've got a pic16f1574 pwm driving some led's. What i'm trying to achieve is to have the LEDs dim to almost off, then increase brightness, then repeat.
What happens is they seem decrease properly, then skip the increase phase and go straight back to decrease, then randomly switch to increasing, skip the decrease and go straight back to increase, then randomly work properly for 1 cycle, then go back to whatever it feels like.
I expect its bad code, but i cant figure out whats wrong.
any thoughts?
usinc MPlabx and XC8
Main.c
What happens is they seem decrease properly, then skip the increase phase and go straight back to decrease, then randomly switch to increasing, skip the decrease and go straight back to increase, then randomly work properly for 1 cycle, then go back to whatever it feels like.
I expect its bad code, but i cant figure out whats wrong.
any thoughts?
usinc MPlabx and XC8
Main.c
C:
while (1)
{
int i;
for (i=600; i>2; i-=10)
{
PWM1DCL = i;
PWM1LDCON = 0x80;
__delay_ms(100);
}
i=1;
for (i = 1; i < 600; i+=10)
{
PWM1DCL = i;
PWM1LDCON = 0x80;
__delay_ms(100);
}
i=600;
}
}
Last edited by a moderator: