Close

Memory

A project log for Z80 Computer

An attempt to build a Z80 computer capable of running CP/M

techavtechav 04/12/2015 at 20:170 Comments

With its 16-bit address bus, the Z80 can access up to 64KB of memory. It has built-in support for DRAM refresh, using the low byte of the address bus to provide a refresh address during the second half of the M1 cycle. I don't have any RAM on hand that would work with something so old as a Z80, so I'll have to order some. DRAM refresh sounds like a hassle (especially using such a slow clock starting out), and isn't currently available in through-hole packages or 5-Volt, so I'm going with the obvious choice of SRAM. To try and minimize chip count, I'm going to use a pair of 32KB SRAMs with A15 selecting between the two.

As for ROM, I have an old Crestron touch panel built primarily with socketed ICs, including four 512KB AMD AM29F040 Flash memory chips. My plan is to use the lowest 32K of one of them and bank switch with the low RAM. This will put my ROM at address $0000 on boot, so I don't have to try to feed a 3-byte jump instruction on reset. I've seen a number of different ways to pull off the switch, but what makes the most sense to me is to put a register on the IO Bus that handles the swap.

What I'm thinking is a pair of 4-to-16 decoders on the address bus, enabled by IORQ (which I'll need for peripherals anyway). A high address like $FF will select an 8-bit register. Bit 7 on the register will select between ROM (clear) and RAM (set). On reset, register is cleared, and Z80 starts executing from $0000, which is ROM. ROM copies what it needs into the high RAM (CP/M sits at the top anyway), then jumps up to a routine that will set the bit for bank swap. With this approach, I could use the additional bits of the register to swap out additional pages of the ROM, by connecting them to the address lines above A14.

Before I can do any of this though, I need to figure out how to program the Flash, and I want to back up what is currently on the chips, just in case. My first thought was an Arduino Uno with a couple of shift registers outputting the addresses, and PORTD as data bus with the Flash. I'm sure I could have made it work, but after my first attempt failed, I remembered I had picked up an Arduino Mega from one of the closing Radio Shack stores. I used ports A and C for the first 16 address lines, and since those are numbered as digital pins 22-37, I just used 38-40 as A16-A18 (though I would really like to know whose idea it was to number the pins on the Mega in such a haphazard way, with some ports counting up, some counting down, and some just mixed at random). PORTK was data, and PORTE serial and control signals. I can read the entire memory and output it as ASCII-encoded Hex over serial at 115200Kbps in no time at all.

Now I just need to make sense of the datasheet and figure out how to erase and write to the Flash.

Discussions