> Olin, I jumped to the same conclusion as you initialy which is why I asked > the OP for some more information. He is not using PWM to produce e.g. a > sine, but is simply setting the pulse width to 50% and using the CCP as a > simple square wave tone generator. The filter he requires is not there to > simply remove the PWM carrier, which would be trivial. Unfortunately the > desired range spans several octaves which requires a tracking filter as > described by other people. Yeah, I saw this several posts after I sent my response. Part of the reason I assumed this was because it made sense, allows for arbitrary waveforms, and gets around all the dynamic filter problems being discussed. > The idea of a switched capacitor filter is nice, apart from the fact that > the clock you must supply is a fairly high multiple of the filters corner > frequency, i.e. 50 or 100 times, so driving such a filter directly from the > CCP module is not possible, you'd need some way of upping the frequency e.g. > phase locked loop, and it all starts getting a bit complicated for a simple > project. A switched capacitor filter just switches in/out elements of cascaded R/C lowpass filters. You only switch it to change the rolloff frequency. It is a passive filter in any one configuration, and does not require a clock. You have a chain of resistors in series with capacitors to ground thru a FET between them. Turning on a FET enables that R/C filter section. Another possibility is to have a chain of such R/C filters at successively lower cutoff frequencies. These are unswitched fixed passive filters. Every two stages or so tap off the output into an analog mux. Select the mux output based on frequency so that the harmonics are sufficiently attenuated without the fundamental being attenuated too much. Since he's using square waves, he's got a factor of 3 in frequency between the fundamental and the first harmonic content. However, I would seriously investigate doing it the way I assumed he did it in the first place. It will greatly simplify the analog electronics, although you have to wake up and think about the software a bit more. I have used this scheme to generate various wave shapes before. In one case the wave shapes were all the same, so I had one lookup table with more resolution than I really needed. This allowed using the "pick nearest" method without interpolation being required at the expense of extra table space. The frequency was controlled by how much was added to the table offset each PWM interrupt. I kept 16 fraction bits to avoid creep when rounding to a particular table entry. And yes, it worked quite well. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.