The Z80 must be supplied with an external clock source on pin 6 for most if not all Z80 DIP packages. A clock source is one of the most useful de-bugging tools that you can use in developing a Z80 system. The clock allows you to monitor the function of your system at a speed you choose. We would like a low-frequency square wave clock pulse train to drive our system, and the lower the frequency the better.
The range of around 1Hz – 20Hz is a great frequency range to shoot for when designing a low-frequency clock circuit. This is because of flicker threshold. Somewhere around 20Hz or twenty cycles per second humans have a hard time perceiving a change between light states. For instance if you were to connect an LED to a 20 Hertz square wave you would find that the LED does not appear to be blinking, but rather just illuminated and stable. It would not be beneficial to run the system much higher than 20 hertz while debugging because we would not see each transition the Z80 is making.
The maximum amount of clock cycles the Z80 takes to execute an instruction is around 20 clock cycles. On the low side of the instruction cycle count is the ‘NOP’ and ‘HALT’ instruction which each take 4 clock cycles, so at 20 Hertz it would only take 1/5 of a second to execute, whereas at 2 Hertz it would take 2 seconds to complete a ‘NOP’ or ‘HALT’. So in general slower is better to see transition.
You also want to strive for a 50% duty cycle clock source which is what the Z80 microprocessor requires. This means that the square wave is high the exact same amount of time as it is low. There is some leeway on this requirement, but I would say that as a rule of thumb try to keep it within ~(+/-)10% of 50% duty cycle.
The schematic that I have followed to realize this clock source can be seen below. This schematic produced a frequency range of around 5Hz to 20Hz. I used a calculator to find these values from this website, OhmsLawCalculator. A similar circuit can be seen in the 555’s data sheet under “Astable operation.”
A low-frequency clock source is very useful in debugging, but counting cycles and remembering where you are in conjunction to the Z80’s operation can be hard. A better option would be an instruction-stepping clock. This source would take advantage of the Z80’s WAIT (pin 24) and M1 (pin 27) signal pins to run each instruction individually through a de-bounced button press. Each time the user presses the button an instruction would execute fully and wait for the user to press the button again to execute another instruction. With a monitor device on the bus such as a bank of LEDs, the user could verify the computer is functioning exactly as desired. I will be developing an instruction-stepping clock in a later post, and will explain more about its function.
All files from this project can be downloaded from my GitHub Repository,