MCH wrote: > Any Assembly code examples you could point me to? There are probably several out there, but this is so simple, just write it. > How much resolution would I need? 8-bit? 16-bit? More? I want a > pretty pure sounding since wave. You have to decide what signal to noise ratio "pretty pure" is. 60dB, 80dB= , 96dB? In engineering we need real numbers. You can't design something if you don't know what to design. If you don't know how to quantify "pretty pure", then that is the first design task. Since it's just a sine wave in the 600Hz to 2.5KHz range, you can do some post-filtering and get away with quite low resolution. Think what the harmonic content of a sine wave with 8 bits resolution is. Let's say you want the filter not to change the amplitude over your frequency range much. Two poles of low pass filter with 5KHz rolloff frequency won't effect your signal much, but will eliminate just about all quantization noise. Put it another way, you can get a nice sine wave with sufficient low pass filtering of a square wave, so starting with a 8 bit resolution sine wave i= s way easier. > I have been searching for hours, You'd be done now if you spent the time instead just writing the code. Thi= s is pretty simple stuff. > I guess it's really the table > that is the crux of the matter and not necessarily the PWM part, Don't guess, know. Actually the sine table isn't the issue, selecting the right PWM tradeoffs is. Do the math, and then you can tell for sure what the PWM needs to do. Let'= s say you want a minimum of 60dB signal to noise ratio, and you post filter with two poles of LPF at 5KHz as I mentioned above. This filter needs to attenuate the PWM frequency by 60dB, or by 1000 in voltage, or by sqrt(1000= ) =3D 32 in voltage per filter pole. 5KHz x 32 =3D 160KHz, which is the mini= mum PWM frequency you need to achive 60dB signal to noise ratio. A 18F4550 can run up to 12MHz instruction rate, which is also therefore the maximum PWM clock rate (I think, your job to look up). 12MHz / 160KHz =3D = 75, which is the maximum resolution minus 1 a 160KHz PWM from that PIC can have= .. That's only a little more than 6 bits (log2(76) =3D 6.2 bits equivalent), b= ut as I pointed out above, resolution isn't that big a deal with the right filter. However, after looking all this over, I think 3 low pass filter poles will be better. Three at 5KHz will bite into the amplitude of the signal at 2.5KHz a bit. I don't know whether that matters, since you said nothing about amplitude flatness. Still, lets move the filters out to 7.5KHz and use three of them. Now the minimum PWM frequency for 60dB is 75KHz, and resolution is 161. This is all cutting it close right at 60dB. Personally I'd want it a bit better than that and leave some margin. I'd probably use something like 6 bit resolution, which would give you a PWM frequency of 191KHz. With three LPFs at 7.5KHz, the PWM frequency will be attenuated by 84dB. Also keep in mind any audio system is going to further squash frequencies in that range, and of course they are way above what you can hear. The real reason for bothering to get rid of them is that they can cause undesirable things to happen in the audio electronics. The significant harmonics of a 64 bit sin= e wave will be many multiples above the fundamental, so the filters should squash them nicely. If you don't care about amplitude flatness, then move the filters lower. Move them as low as you can tolerated the amplitude variation accross your frrequency range. If you want to get fancy, you can add a automatic gain adjusting circuit to the output, which will let you move the filters much lower. However, that is not a beginner circuit. ******************************************************************** Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products (978) 742-9014. Gold level PIC consultants since 2000. --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .