Wiring a Z80 to Arduino...

Hello

I'm trying to connect my arduino Mega to a Z80A chip taken
from an old Amstrad CPC computer.

The final goal is to build a Z80A computer and then don't use
the arduino anymore. But for the present time, I only have the Z80A &
the arduino, no memory chip nor EEProm programmer nor memory
decoder etc. So I thought the arduino could provide the vast
majority of inputs or outputs to the Z80A (eg: RESET pin,
CLK pin, address bus, data bus, etc).
It's only an educational project, I've learned Z80 assembler 30 years
ago, and digital electronic 20 years ago but never got the opportunity
of trying it for real!

After a few hours - late at night - of trial and error, I still
can't make it work. Damn it!
My electronic skills being really basic, I suspect them to
be the cause. (I'm a software writer, so I don't have too much concern about the 'code writing' part...)

Here are my too concerns:

1/ As the arduino and the Z80A both run on 5V, I thought I could directly
connect any pins from the arduino to the Z80A. But the Z80A started to get
very hot, so I think there is a problem! I've read somewhere that Z80A
worked at something like 5V@90 mA (not sure, I have the exact figure at home)
and the Arduino deals 40 mA per I/O pin. I don't see why it would overheat
my poor old Z80A... I've tried to add a 100 ohms resistor between the
Z80A and the ground, it got cooler but always ended up very hot. Maybe
it's its standard temperature, but as it is an old chip and I've had hard
times to find it, I'd rather not burn it!
I could insert a resistor between each arduino-Z80A connexion, but it's too
random and I don't have that many 100 ohms resistors right now!

2/ My second problem is that, when I spy the addresses required by the Z80A,
I've got 0, 3, 7, 3, 0, etc... then 15 sometimes...
I've just written a program for the arduino to send 0xC3 (JP) when the 0 address
is requested, or 0 for any other address, so it will code a JP 0 and forever
loop.
So I'd expect it to request 0 (fetch JP = 0xC3), 1 (first part of the addess), 2 (second part of the addess => jump back to 0), 0, 1, 2, etc...

The hard part is that, since many of interesting pins of the Z80A are active-low, it's not easy
to know if the thing is working or not because I merely get tons of zeros from the pins... !
Which makes me think that... I've only checked the RD pin. I could check the WR pin too,
because there's a chance that they are opposite...

If anybody has an idea...

Regards
Bozgrul

I think it would be a good idea if you posted your schematic.

AWOL:
I think it would be a good idea if you posted your schematic.

OK, I'll post it tonight, being at work for the present time.
But it's fairly straigthforward, Z80 pins are either connected:

  • to arduino 5V output
  • to arduino GND
  • to any arduino digital pin I have chosen (ie : clk is connected to pin 53, and the arduino sketch sets the 53 pin down, up 100 ms latter, then again up 900 ms latter, to get a 1 hz frequency)

clk is connected to pin 53, and the arduino sketch sets the 53 pin down, up 100 ms latter, then again up 900 ms latter, to get a 1 hz frequency)

From my (dim and failing) memory, the clock was a symmetric square, not a 10% duty cycle.
Phasing of signals is critical, because things like memory or I/O operations are triggered on particular edges.

Dredging things from my memory I seem to recall that the internal registers of a Z80 are made from dynamic RAM therefore there is a minimum clock frequency. I am sure 1Hz is way too low for the processor to operate.

I think it was fully static - though it did have a register that could be used for DRAM refresh.
(My first z80 chip cost about £40, which was about the average weekly wage at the time!)

EDIT: Quick google suggests Hitachi variants had dynamic elements, but not the Zilog ones.

I can think of so many issues here I hardly know where to start.

You can't supply a clock signal to the Z80 from an IO port, you need a high frequency, about 2-4MHz.

The Z80 has NO IO pins, everything is memory or IO mapped at high speed. There is no practical way to directly connect the two chips. You will need latching hardware but the Z80 still needs ROM and RAM to run.

But the Z80A started to get very hot

The Z80 may just run hot, it's a very old chip.

I've had hard times to find it, I'd rather not burn it!

Z80s are still produced and easily found.

when I spy the addresses required by the Z80A,

What do you mean "spy the addresses"?

I've just written a program for the arduino to send 0xC3 (JP) when the 0 address is requested, or 0 for any other address, so it will code a JP 0 and forever loop.

How will you do this? You have to test the 16-bit address against 0000, turn the data direction around on an Arduino port, then write 0xC3 followed by 0x00 and another 0x00. All within the cylce time of the Z80.

If you just want to test the Z80 you can easily do that by pulling all the data lines constantly low (00 = NOP), the Z80 will cycle the entire memory map and you can view the address lines with a scope.

I must say I love the idea of building a Z80 computer, just for the shear retroness of it, but I don't see how an Arduino can really help unless you want to make what is affectively an EPROM emulator.

In this case the Arduino can be very useful.

To do this your Z80 needs RAM and IO chips and per normal, it also needs an EPROM to run the code from but you substitute a RAM for that and dual-port it with some octal buffers. Now you have an EPROM emulator and you can compile Z80 code and download the HEX file to your Arduino which in turn dumps it into the RAM that is emulating the Z80s EPROM.

It's much easier than I probably made it sound.

I've done similar many times (a while back I admit) and can help if you really want to do it.


Rob

You can't supply a clock signal to the Z80 from an IO port, you need a high frequency, about 2-4MHz.

No, you don't.
My first breadboarded Z80 had a debounced toggle switch for a clock generator.

Yes AWOL is right it can work with a DC clock, I have just looked up the data sheet. It brings back memories.

Geek warning:-
Did you know that in one Dr Who episode the master had tamped with the program running the universe. He had his assistant read out the code, it was a stream of hex numbers. On a certain string of numbers the Doctor said "That's it", if you knew Z80 machine code hex, that string of numbers was a jump to subroutine call. Some one on the script team must have put that in.

Well it's been a while, I thought I remembered them as being dynamic.

It brings back memories.

Me to. I had a Microprofessor development board once and recently found out that they still make them. I couldn't believe it, but can't imagine who uses them.

I'm almost tempted to make a Z80 board just for the sake of a trip down memory lane. You can still buy the CTC, SIO, PIO, DART etc. I used Z80, Z8, 64180 and Z8000 over the years. In those days it was pretty much Zilog or Motorola. Then I went away from embedded stuff for 15 years and when I came back that had all changed.


Rob

After I got bored toggling in programs (no cassette storage and no UV-EPROM programmer), I bought a Nascom 1, but still couldn't afford an assembler, so I became very adept at hand-assembly - I still remember that "INC HL" is 0x23.
How sad is that?

How sad is that?

Pretty sad, but I think I can do better.

I used to lie awake at night dreaming of the 68000 and wondering what I could do if I could afford a processor as powerful as that.

And speaking of the 68k, the mob that makes the Z80 development board also does a 68000 board, complete with the 64-pin "aircraft carrier" pack CPU.

Who uses this stuff?


Rob

I had a Microprofessor development board

{ Googles } £270! That's what a Nascom 1 cost 30 years ago!
And it had a better keyboard.
And a video output.

I suspect I still want one, for old-times sake.

Thank you for all your answers that I read really carefully.
Who said that no one is interested in such oldies? Not me ! :slight_smile:
I will try again tonite, and follow your advices:

  • use a real square signal for the clock (but at soon as I will get it
    working, I will try changing clock parameters to see how the Z80 performs
    under different clock signals or even manually - with the anti-rebounce)
  • bind D0-D7 to GND to permanently send a NOP opcode (brillant idea, I feel stupid that I didn't have it before you tell me!)
  • keep the design as simple as possible. I still have a few outputs of the Z80 that I can discard for now, I will care latter (WR or IORQ for example, since I will only read the whole memory)
    I will take more time tonite to answer you, when I'm back at home.

Bozgrul

Oi! Who are you calling "oldies"?

I'm talking about the Z80 of course, no offense.
But maybe it's a joke !? :slight_smile:
Sorry, english is not my mother-tongue.

@bozgrul35
I take back some of what I said before, given that we've determined the chip is static you could probably make a sort of CPU emulator that controlled the clock and looked at addresses then supplied data. A sort of hardware-based simulator.

Here's a good reference page


Rob

Rob, that's exactly what I had in mind.
In fact, I read a blog page a few days ago,
where the author gave good explanations about the Z80.
And he did the same page about the 6502 (I'm expecting one,
bought on ebay) but explained the difference, because of dynamic registers.
(The First Great Z80 Project)
"... It is worth noting that the Z80 is the only major computer CPU in the history of microelectronics that does not use any dynamic registers. Dynamic registers function much like dynamic RAM (DRAM) in that they must be constantly refreshed, or they lose their contents. Virtually every other CPU that was widely used, from the 6502 to the 80x86 family, uses these dynamic registers, and so they have a minimum clock speed which must be maintained for them, or their dynamic registers will lose their contents. The Z80 is so stable that it can actually be stopped at a standstill and still not lose its data. In fact, you can even set up a circuit to hand-clock it with a push-button switch. (If you do so, however, you must connect the button to the clock input pin through some stabilizing circuitry so that it produces a clean rise and fall, instead of a ragged, unsteady rise and fall.) ..."

I didn't find this site (http://www.z80.info/) before, even if I have searched a whole lot of ones the last few days.
Looks promising!

It is worth noting that the Z80 is the only major computer CPU in the history of microelectronics that does not use any dynamic registers.

Not so; the 6800 and the 6809 were both also fully static.

Also the Signetics 2650 was fully static and pre dates the Z80 by a couple of years.
It was used in the first Phillips games consoles and was the first Micro computer I built in 1975. I used it in a couple of embedded systems as well, including the first micro processor controlled ham radio repeater in the U.K. in 1976.

My first computer - home built and designed