I was just messing around with PWM on the TI Launchpad and I want to make an LED simply fade in and out.
Now my problem is, that the LED fades in and out once and then it just jumps to full brightness. I don't know why this happens (on the AVRs I solved the problem by not counting down to 0 and everything was alright but that doesn't seem to do the trick for the MSP430)
Here is my code (the bit that fades the LED):
for(i = 1; i < 999; i += 10){ CCR1 = i; _delay_ms(10);}
for(i = 999; i > 0; i -= 10){ CCR1 = h; _delay_ms(10); }
I hope one of you knows where the problem is!
Torrentula
BTW: _delay_ms() is a simple delay function I wrote based on _delay_cycles(1000);