> At 04:17 PM 7/23/2008, Tom Van Baak wrote... >>I just prototyped this PIC algorithm and it works perfectly: >>Exactly 10 MHz in gives exactly 32.768 kHz out. > > TPIWWSC. > > (This Post Is Worthless Without Source Code) > > :-)
Hi Mike, Yeah, I thought I provided enough information in that posting so that anyone that's programmed a uC before, or has seen the free source code to the 1PPS PIC divider would get the idea. By the way it's almost the 10th anniversary of that PIC divider: http://www.leapsecond.com/pages/ppsdiv/ OK, you asked about the prototype for the 32 kHz algorithm. See: http://www.leapsecond.com/tools/10m32k.c The basic idea is as I described a few hours ago; with a correct combination of 38 and 39 cycle instruction code paths, you get a 32 kHz output that has some jitter in phase but has perfect frequency accuracy from one second to infinity. This is similar to the case of the special 100 kHz output of the PPS divider. The cute algorithm that I prototyped is one that is inspired by the way we handle leap years. The result is that all the "leap cycles" are as evenly spaced throughout the second as possible, both minimizing jitter to the extent possible with a 400 ns PIC cycle time, and maintaining an absolute division of the 10 MHz to 32.768 kHz, as averaged over any multiple of 1 second. There are comments in the C code. Note this is not PIC code; it is simply my proof-of-concept (compiles under windows or unix) for isochronous PIC assembler code that can (will?) be written. If I know you PIC'ers with spare time out there (not me right now) it will be done by tonight. It should be end up on the order of 40 lines of careful isochronous assembler code. I assume the AVR would work too. The result will be a $1, 8-pin, single-chip, 10 MHz to 32 kHz, low (not zero) jitter frequency divider, suitable for driving cheap digital or analog clock and watch movements from a 10 MHz source. Extra credit for the 5 MHz version. /tvb _______________________________________________ time-nuts mailing list -- time-nuts@febo.com To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts and follow the instructions there.