We need to run our CPUs either at full speed (whatever that is) or at a predictable slow speed for debugging using a probe like an Arduino Mega.
I've experimented with increasing the speed of Ben Eater's clock module but it has its limits:
- the shape of the square wave gets distorted a bit as speed increases
- I want a clock where I know what the speed is: discrete settings rather than an analog dial
Ben's single-step mode is hard to beat though.
Time to learn about building crystal oscillators and using frequency dividers...
The OscillatorAfter much googling and reading, this is where I ended up. So, since I already had some 20 mHz crystals on the bench from AVR projects, I went out and bought a range of small ceramic capacitors at my local electronics store and set to work testing the resulting signal on my oscilloscope.
More googling and several variations on using a binary ripple counter as a divider appear to be popular. The CB4040 (also exists as a 74HC4040) was the easiest 14 bit ripple counter to get my hands on so that's what I went with. Circuits using other variants will be very similar.
Even though the 4040 is a 14 bit ripple counter, in the 16 pin package of the IC they skip Q2 and Q3. Much of what I found on Google for this subject was just plain wrong about the actual outputs.
Of the 14 bits, bit zero would be the input. signal ("Q0").Q1 gives you /2, /4 and /8 are missing (Q2 and Q3), and then they are all there from /16 through /16384 (Q4..Q14).
The speeds shown on my dial may not be exact, but they are reliable. I needed to drop the decimal places to make it fit on the print. The data below shows the theoretical frequencies compared to what I measured with my oscilloscope (and then how I rounded up for the cover plate).
I've used it to run my 6502 machine at 10 mHz with no issues. I've also used it to slow the machine down for using my Arduino monitor / disassembler reliably at 20 kHz. I can run at 40 kHz with the Arduino but it will occasionally skip a beat (the Mega just isn't very fast despite all my optimizations.. but it does have a lot of pins).
Comments
Please log in or sign up to comment.