On Sun, Mar 02, 2003 at 01:25:43PM +0100, Wojciech Zabolotny wrote: > > However the main problem is how to generate the square waves with the > programmable frequency... Can it be done with the CCP module? (I need only > one edge to be jitter free - all external circuits can be "raising slope > triggered", so the jitter of the failing edge does not matter at all). > > Could it be done as follows? > Both CCP work in "compare, set output on match" mode (0x1000). > After each CCPxIF interrupt, the pin CCPx is reset by software, and the new > CCPRx value is calculated as follows: (PULSE_LENx - the period of the > square wave) > CCPRx = (CCPRx + PULSE_LEN) modulo 0x10000 > Probably this method should even be used to generate a symmetric waveform, if it is possible to change the mode "on the fly". Just after each interrupt the mode should be chnged from 0x1000 to 0x1001, and after the next interrupt from 0x1001 to 0x1000. So single TIMER1 + 2 CCPs should be able to generate two symmetric waveforms with different frequencies and jitter-free slopes. (however the interrupt rate will be high). Is it correct? -- Wojciech M. Zabolotny http://www.ise.pw.edu.pl/~wzab <--> wzab@ise.pw.edu.pl http://www.freedos.org Free DOS for free people! -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu