On Wed, 17 Apr 2002, Bob Ammerman wrote: > At low PWM frequencies you can switch from using hardware PWM to doing it > with some software assist (ie: in an interrupt handler). You'll probably end > up with a bit of jitter in the result, but it will usually be acceptable for > most applications. I agree. I have a couple comments (and I haven't read the whole thread so these comments may not be appropriate). Varying the PIC's oscillator frequency is a perfectly reasonable approach to obtain a lower frequency PWM. In one application I needed a constant duty cycle, but variable frequency PWM. The frequency was controlled via a POT as part of the R in an RC oscillator. For the software approach, I can imagine several different solutions. One is to manipulate the PWM registers in such a way that the oscillator frequency can be made slower. For example, you (Jinx) could re-write TMR2 or change the mode of the capture/compare/pwm (e.g. disable the PWM functionality until it's needed). Another software approach is to write an interrupt driven software PWM routine. It would be much coarser than the hardware PWM. Furthermore, it will not transition smoothly between software - hardware - software PWM control. If you want smooth transitioning, then you can implement a single cycle resolution PWM routine: http://www.dattalo.com/technical/software/pic/pwm256.txt But I think that may be a little overkill :). OTOH, you could ditch hardware PWM altogether with this routine and control the PWM with any dutycycle/frequency you'd like. The only problem with this routine is that it's been known to induce migraines. BTW, as listed this routine is only an 8-bit PWM. However, I've used it to generate 12-bit pwm too. Extending it to 16 or 24-bits is, well not trivial, but doable. A 24-bit PWM driven by a 20-MHz crystal will yield an oscillation frequency of 0.298 Hz. If that'a not low enough, you can add 8 more bits and drop it down to 1mHz! Scott -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads