Barry Gershenfeld wrote: >> Hello, >> I am in need to divide a 12.5 Mhz clock by 163. How can this be >> done with a counter? I know that if this division were a power of >> two, then it would be very straight forward, but this is not my case >> at all. Any pointers will be greatly appreciated. -Vic > > If only it were an even number this would be straightforward. But > you had to pick 163. Otherwise you divide by 2 at the end and > the result is square. I don't suppose you could fudge it to > 162 or 164... > > Barry There are some ways, including microcontroller counting pulses, but 12.5MHz is a little bit high for an AVR executing NOPS for example, with an intermediate flipping output port pin for an almost square wave. 1) First Solution ----------------- You need to build a double polarity pulse discriminator, integrate into a exclusive or, and get two sharp pulses for each complete 12.5MHz squarewave. You will have exactly 25MHz in pulse shape at the output of the EOR. Then you use the 25MHz to step two 74HC4020 and use the Q7 output to drive a counting into a 74HC4017, use ouput Carry-Out (pin 12) to drive another 74HC4017, output pin 5 (Q6) will be your division by 163. The only way to have a square output is to divide a frequency by an even number, this is why you need first to multiply the frequency by 2. +VCC | R01 | .---||--o----. ____ | |__|| \ 12.5MHz-----o __||EOR O----> X | | ||___/ 25MHz '---||--o----' | R02 | _|_ ___ ___ ___ ___ 12.5MHz___| |___| |___| |___| |___ ___ ___ ___ ___ ___ ___ ___ ___ ___ 25MHz | | | | | | | | __________ _______ _______ | | | | | | 25MHz---| 4020 |Q7--->| 4017 |12--->| 4017 |5---> 76687.11656 Hz |__________| |_______| |_______| _ _ _ _ Dividing by 326 _| |_| |_| |_| 2) Second Solution ------------------ _________ | | | 4017 |Q3--. |_________| | | | 4023 ___12____ | ____ | | |____| \ | 4017 |Q5_______| o----o-----> 76687.11656 Hz |_________| ____| | | | | |____/ | 12.5MHz---o | | | | <-------' ____|____ | - Reset to | | | All chips | 4020 |Q6--' |_________| Dividing by 163 But this solution generates a non square wave at output, simply a negative fast pulse that is also used to reset all chips /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ Wagner Lipnharski - UST Research Inc Orlando FLorida - USA - www.ustr.net /_/_/_/ Atmel AVR Consultant /_/_/_/ -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu