Hi Speck,

It can always be done with a hardware PWM and low pass filter. See my sinewave inverter thread http://www.picbasic.co.uk/forum/showthread.php?t=1846 for a code snippet that does this at an update rate of 100Hz driving a half bridge. Scaling the sine table is impractical with only 8 bits of resolution. For example if you define your sinewave lookup table to produce the maximum peak value into an 8 bit one then you have to do fractional math.That is your modulation index (depth of modulation) is <= 1. (The dSPIC supports fractional math). So the trade-off is multiplying the lookup table with a 8bit value and shredding off the LSBs. This works okay for low fixed frequency. If you do a cycle by cycle computation then the overhead is manageable. But for a 20K function generator to work with a base frequency and modulating frequency it has to be updated every PWM interrupt cycle. That is too much you could ask for a 16F PIC @ 5 MIPS. The 18Fs have an extended instruction set featuring a single cycle hardware multiply that too @ 10MIPS. In fact you can use Darrel's Software PWM http://www.pbpgroup.com/modules/wfse...p?articleid=12 to make your life easy. It takes of all your pain in doing it in asm.

BTW the PIC Hardware PWM uses upto 10bits and it is a good practice to set your PR2 to $FF. That is where you get the maximum usable PWM resolution.