That is very true. I added a pause of 50mS in each button press if-endif routine.
The problem with that is the LED's flicker each time the button is pressed. Not sure why the pause should effect the PWM. I thought that the PWM was continuous unless you turned it off with CCP1CON = 0. That was my basic understanding anyway and the theory behind the idea. Run pwm continuously and vary the duty cycle based on a target current limit and the actual feedback results. Add or subtract by one the duty cycle number until the current limit is achieved.
Also the LED's flicker when ever there is a WRITE command so I created a counter that only writes the value every 25000 cycles.
Bookmarks