On Fri, 9 Jul 2004, Russell McMahon wrote: > [EE:] Design Challenge - Lowest cost PWM I've written an all-software version that has single instruction cycle resolution and can run on the 12-bit cores: http://www.dattalo.com/technical/software/pic/pwm256.txt It has an 8-bit dynamic range (though in one instance I boosted this to 12-bits). The PWM frequency is fosc/4/256, or about 20kHz for an fosc=20Mhz. The algorithm leaves available roughly 50% of the CPU time for other tasks. So in your case where you need to receive either an analog or digital control, you'd have CPU time to implement it. I promise this routine will make your head explode! It's completely isochronous and uses the program counter as a control variable. But with the new PICs dropping below $0.50, I think this implementation may be optimal in the cost * flexibility solution space. If flexibility is not a desirable feature, then your hardware-only solutions will most probably be cheaper. Scott -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu