John Payson wrote: > [4] One style of "PWM" that I've not seen implemented in hardware > even though a hardware implementation would be easy works as > follows [the MSB of the output value is bit -1; the LSB is bit -n] I'll figure that out sooner or later. ... OK, I've got it! > In addition to its simplicity, it benefits from a minimal amount > of ripple: for the extreme values of 1 and 255, the ripple will be > the same as with normal methods; for values in-between, the ripple > will be much less than what ordinary PWM would produce. I tend to consider the "standard" way to do PWM, that used by the BASIC Stamp. For every iteration, you add the "width" to an accumulator and you set the "PWM" output bit according to the carry. movf width,w addwf accum,f ; C flag now indicates desired PWM state; up to you to output it! This most certainly fulfils the "minimum ripple" criterion above. In fact, I suspect the bitstream is identical to John's proposition. Code is simpler but his does use fewer registers when multiple channels are employed. -- Cheers, Paul B.