The Z80 CPU runs from 5V@~90mA

The original Z80 processor can be driven from DC to 2.5 MHz (the Z80A runs to 4 MHz – the one we are focusing on)

So, in order to get the Z80 to run – we need proper power and a system clock.

To get up and running quickly and to provide some flexibility, I am going to use a PIC10F322 to generate the clock signal and hold the processor in reset after power is applied to allow the power to stabilize before releasing the reset.

A PIC10F322can be programmed to output a reference clock. The values it can output are, 4Mhz, 2Mhz, 1Mhz, 500Khz, 250Khz, 125Khz, or 7.75khz.

For this fun project, I will program a reference clock of 125Khz. The clock will be feed into the Z80 Clock pin (6) with a 330Ohm pull up on the clock line. PORTA.2 is the reference clock out on the PIC10F322.

PORTA.0 from the PIC10F322 will connect to the Z80 Reset Line – Pin26 (Active Low). This line will be tied to ground VIA a 10K pull down. This will keep the Z80 in reset, until the 10F322 pulls the line high – after about 500ms (a lot longer than needed) after power on.

PORTA.3 of the PIC10F322 we will attach a pushbutton – normally open to act as a reset. When triggered will drop PORTA.0 low – resetting the Z80 CPU.

Here is the Circuit Diagram

Project Z80 - Clock and Reset Circuit

Here is it laid out on the breadboard

Project Z80 - Clock and Reset Circuit

And how do we know this is working…. D2 is the M1 line from the Z80 CPU
On the Z80 – The M1 line will be pulled LOW doing the start of a machine cycle – to indicate the fetch of an OP code.

It is trying to load – however there is nothing for it to load. Yet..

Timing Logic showing the M1, Reset, and CPU Clock.

 

Project Z80 - Clock and Reset Circuit

The code and include files can be found here in GitHub - https://github.com/JamieStarling/MCU_FUN/tree/master/Microchip/PIC10F322  z80_reset_clock.c

#include "includes/10F322_deviceconfig.h"
#include "includes/osc.h"
#include "includes/gpio.h"
#include "includes/wpua.h"





void main(void)
{
    cpuFreqSelect(KHZ500); //Set CPU Freq to 500Khz
    enableClockReferenceOut (); //Set Clock Reference Out
    
    pinMode(0,OUTPUT); //Set PORTA.0 Output
    digitalWrite(0,0); //Set PORTA.0 Low
    
    enableWPUA(3); //Enable Weakpull Ups PORTA.3
    
    __delay_ms(50);  //If you change the CPU Frequency Update _XTAL_FREQ in device.h
     
    digitalWrite(0,1); //Set PORTA.0 High - Bring Z80 out of reset.
    
    
    
  while(1)  
  {
      if (!digitalRead(3))  //Read the reset Button - if low
      {
          __delay_ms(50);  //Wait 50ms..
          
          if (!digitalRead(3)) //Check it again.. if still slow reset Z80
          {
              while (!digitalRead(3)); //Wait here until button is released
              digitalWrite(0,0); //Set PORTA.0 Low - Z80 Reset
              __delay_ms(100);  //Wait 100ms
              digitalWrite(0,1); //Set PORTA.0 High - Bring Z80 out of reset.
          }        
      }      
  }
    
}

–FUTURE PLANS

The PIC10F322 is limited by the number of output pins (4). I will need to use a larger PIC processor to start with.

To expand on this – Add single instruction stepping.

The idea is to use the M1 and Wait lines.

As we know – M1 goes LOW at the beginning of every instruction fetch cycle. Ml signifies that the computer has completed one instruction and is starting on the next.

We would stop the CPU before it executes the next instruction.

And the WAIT line does just that. A LOW signal on WAIT holds the CPU as long as you want in the M1 cycle. When WAIT is back HIGH, the CPU will resume.

Will need to add a switch and button to the PIC. The switch to change run modes and the button to single step.

Maybe, I will even add some interface to the PIC allowing for changing of the CPU clock. That is what I like about this stuff. Whatever you can dream up – you can create.