On Sun, 16 Nov 1997 15:25:29 -0500 Dave Celsnak writes: >Thank you all for your help with the Compare Mode. >It seems I have figured out my problem. Too many interrupts from the >main >code. I have a software 'serout' command that doesn't like to be >interrupted. Make the serial port run on a timer interrupt. The main program would service the CCP. Without careful programming, there may be some interruption in the output frequency when receiving and parsing serial data, but the serial data is likely going to change the output frequency anyway. Or upgrade to a PIC containing a hardware USART. If you're using 28-pin ones already to get the CCP or PWM units, the USART ones will fit the same socket. If you only need an output function, the SSP found in most (all?) 28-pin PICs could probably function to send asynchronous (7 bits anyway), by writing the start bit as one of the data bits. Not very useful to receive asynchronous though. [...] > PWM thru an RC (analog out), then to >a >Voltage-to-Frequency convertor. [...] >Unless anyone can tell me why I should try to iron-out a software >frequency driver???? Using a fully-digital method will ensure repeatability from unit to unit, and accuracy of the output frequencies much higher than could be achieved by your proposed method. The hardware could be much simpler, likely entirely within the PIC chip. No adjustments other than maybe trimming the crystal frequency (for very accurate output frequencies) would be needed. The PWM has only 256 or 1024 output steps. The timer-compare method could have about 64K (or 128K allowing for 1 extra count on one half-cycle for inbetween steps) possible frequency settings between 7.6 Hz and 5 KHz. Using a DDS method the frequency resolution could be practically infinite, though phase noise would still be limited to about 1/64K. Speaking of phase noise, it's going to be hard to keep the PWM frequency from inducing a little FM on the output frequency. When you change the PWM setting, the output frequency will not change instantanously. It will take a long time to reach the final value due to the exponential settling of the control-voltage filter. These issues may not be problems though, depending on the requirements of whatever is receiving the ouptut frequency.