> Help! I need help with the firmware to make an LED dimmer with a > 12C509 PIC running off the internal oscillator. I have been able to read a > pot and dim the LED with PWM, but my source code does not run fast > enough to keep the LEDs from flickering(They are multiplexed 7 segment > displays run off another PIC). I would like to do the PWM at about 1KHz. > That doesn't leave a lot of time to read the pot, etc. The code also > needs to check an input pin and output a pulse on another pin if a switch > is closed for more than 2 seconds. > The resolution doesn't have to be real high and the duty cycle doesn't > have to be a full 0 to 100%, but the closer I can get the better. I > appreciate, any help anyone can give me. I am not good with real time > programming. I guess you have a loop performing key reading, pot reading, LED flicker and output control. Do you pause for the A/D conversion to finish? It's not nessesary. You can start the A/D conversion, and let the converter work while you do the looping. Let the loop poll the ADFinished flag. If the flag says that A/D conversion is finished, read the value and start a new conversion. If the conversion isn't finished, use the value formerly read.