Quote Originally Posted by Joe Rocci View Post
Chris,

For now, I only need to compare the first and last bits each time I update the SR. In the future, I might wat to look at intermediate bits. I can pick a PIC (say that a dozen times!!) with as much memory as I need, even an 18F part if that's what it takes, so no prob there. I think the primary limitation on how much other processing I can do will ultimately be determined by how much throughput is left (time). There are a few other tasks having to do with data acquisition (input)and disposal of the results (output), but they're minor as of now. Of course, the more horsepower that is left after the important job is done, the more 'feature creep' I can build in.

FYI, the application is a 'stabilizer' for a voltage controlled oscillator, similar to a PLL. It works by sampling the instantaneous oscillator state with a precise time base, and comparing the present state with the state "n" samples ago. The result of the sampling and comparison process is used to pump the oscillator fine-tuning voltage up or down until the oscillator locks onto the nearest 'comb' point. The spacing of comb points is determined by the sampling rate and the number of samples stored in the SR. It has the advantages of fine tuning resolution combined with fast acquisition and tracking speed, parameters that are usually mutually exclusive in a PLL synthesizer.

Thanks

Jjoe
That sounds very very cool !

Just a look at the processing time......(your minimum execution time assembly example)

2000 bits = 250bytes = 250 RLF's = 250 clock cycles

At 4MHz (crystal) , clock cycles = 1MHz, shift frequency = 4kHz (1MHz/250)

(There's an obvious connection here between shift frequency and crystal frequency due to the nice numbers), therefore a 10kHz shift frequency requires a 10MHz crystal.
20MHz crystal = 20kHz shift frequency

Okay, now to prove myself wrong that you had already written the quickest routine !

Moving one bit at a time is consuming 250 clock cycles (8 bits = 2000 clock cycles) , and because you only need the first and last bits why not move the in between registers 1 byte at a time, but still shift in the first bit and out the last bit by using a pair of end buffers

Data moving from left to right....
(Every iteration, 2 shifts)
SHIFTS: ] --8.bit input buffer-- + --8.bit output buffer--

After every 8 shifts, move bytes in between buffers
MOVES: ] [SR1000>output_buffer][sr992>SR1000].....[input_buffer>SR8]


iteration 1 : 2 shifts + 4 loop counter maintenance
iteration 2: ditto
.
.
.
.
.
iteration 8: 252 MOVFF's + 2 shifts + 4 loop counter maintenance

Estimated overhead for 8 bits = (7 * 6) + (252 +2 + 4) = 300 clock cycles


Using the first method you have a fixed length execution time of 250 clocks per iteration, and using the second method you have one long execution cycle in every 8 (but it has a much lower processing overhead), and averages about 32 cycles per iteration , leaves more time for processing.

Chris





Now, for each iteration you have 6 clock cycles for shifts, and 250/8 MOVEs, which if yoiu use a PIC 18F and the MOVFF command (1 clock cycle) completes in about 50 clock cycles average (excluding loop counter overehad)

iteration 1 : 2 shifts + 4 loop counter maintenance
iteration 2: ditto
.
.
.
.
.
iteration 8: