Pages: [1] 2 3 4   Go Down
Author Topic: Wiring a Z80 to Arduino...  (Read 8646 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26626
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26626
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34724
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26626
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: May 10, 2011, 04:26:55 am by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 130
Posts: 8620
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Quote
But the Z80A started to get very hot
The Z80 may just run hot, it's a very old chip.

Quote
I've had hard times to find it, I'd rather not burn it!
Z80s are still produced and easily found.

Quote
when I spy the addresses required by the Z80A,
What do you mean "spy the addresses"?

Quote
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
 
« Last Edit: May 10, 2011, 07:58:58 am by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26626
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34724
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 130
Posts: 8620
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Quote
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



Logged

Rob Gray aka the GRAYnomad www.robgray.com

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26626
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 130
Posts: 8620
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26626
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for all your answers that I read really carefully.
Who said that no one is interested in such oldies? Not me !  smiley
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
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26626
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oi! Who are you calling "oldies"?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Pages: [1] 2 3 4   Go Up
Jump to: