Tracy Smith wrote: > The subject you wish to learn more about is: phase accumulators. Do > some home work and search about this on the web. Others have > commented (quite succinctly) on this list in the past. I remember > posts from Paul (not sure which one) and Mike Keitz that were both > very good. So perhaps the archives would be a good place to begin. I thought you were referring to me! But then you said "succinctly". Now I don't know if it was me or not! ;-) Anyway, the phase accumulator generates frequencies which have the same long-term accuracy as your (crystal) clock to the PIC and are totally coherent - if you change the frequency, the new frequency starts from the phase of the old one at the point of change. The resolution is *exactly* what you specify it to be too. What it does have, is jitter. More precisely, the output is *decided* at a sub-multiple of the clock rate, say at 8,192 Hz using a crystal frequency of 4.096 MHz. This means the "decision" interval is 122.070 µs so that is the limit of the "jitter" (+/- 61 µs if you like to look at it this way). If your square waves permit this amount of jitter, this design is quite do-able. In fact, it has to be, as there is no other way of obtaining *any* three different frequencies of integral Hertz from one clock oscillator (using a PIC). Of course, multiplying the PIC clock frequency to 8.192 MHz or 16.384 MHz may permit two and four times better resolution respectively. Other clock frequencies are usable but complicate the maths. The above derivation allows simple binary addition to be used for the accumulators, with an isosynchronous program taking 125 instruction cycles in a loop. Each of the three frequency values is added each loop to its respective phase accumulator in a 16-bit add routine, and bit 4 of the MSB of the phase accumulator is transferred to the corresponding output bit. Preferably, they are in fact transferred to bits in a shadow register which is then written to the port register, so whichever bits change, change together. AND THAT'S ALL! That's the *whole* frequency generation algorithm, believe it or not. No timers (and interrupts *cannot* be used at all). A 12C508 will do the job perfectly (if you can figure out how to use the one remaining I/O to code in the frequency values! Hint - serial comms with a baudrate of 8192 Baud!). -- Cheers, Paul B.