On Wed, Oct 17, 2001 at 08:46:29AM +1300, Brent Brown wrote: > BAJ, > > It is possible to take a raw .wav file and playing it back by simply > writing successive values straight to the PWM register at the > sample frequency. That's why I love this list. A quick, great, easy to implement suggestion. > > When I did this (it was a Philips 80c552 chip, but same principles > apply), I just used an RC filter and then AC coupled it into an audio > amp. I ignored the header info at the start of the .wav file and > played it like it was audio data, the result was just a slight click at > the start of the sound. I set the PWM frequency as high as it would > go. When not producing a sound set the PWM output to 50% (2.5V), > as the data in the wave file is also biased at "half way". Understood. After a quick read of the Midrange manual, I realize that the highest speed I'll be able to run the PWM is 19.5Khz with a 20 Mhz Fosc. The reason is that you start to lose resolution as you crank up the frequency. Since the PWM is 10 bits and I'm not real thrilled at having to fight with splitting the sample to store the lower two bits in the config register. So I plan to zero out the lower two bits and store the sample in the upper 8 bits. > > On my second attempt I used the PWM signal to directly control a > MOSFET H bridge driving a loudspeaker. This was quite a bit louder > (which is what I wanted). I think I'm going to try an LM386 for starters. The circuit here: http://www.reprise.com/host/circuits/lm386.asp Seems simple enough. Thanks for the info. BAJ -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.