Wednesday, August 24, 2016

The Programmer

Programming PROMS, as mentioned earlier, is a total PITA if you don't have a programmer (which I didn't). When designing the Z80 CPU portion, the decision was made to have just RAM rather than RAM and ROM. The interface between the Z80 and the single RAM chip was straightforward. All I have to do to take control of the BUS is to assert BUSRQ and wait for BUSAK from the Z80. Once the Z80 acknowledges the bus request, all its control signals are tri-stated. The programmer can then take control of the MREQ and WR lines to program the RAM chip. Since the lines are tri-stated, I probably could have taken control of them directly but I used a MUX (74HC157) as it will also act as a buffer to the expansion port.

I used a Microchip PIC18F46K22 as the controller on the programmer. This is one of my go-to chips that I know is more than capable to handle the job. I also used the MCP2200 USB to UART chip to connect the programmer to the PC that the code will be developed on. I started using this chip recently to replace the older MAX232 type circuit as newer computers don't have RS232 serial ports on them anymore. An added perk to the MCP2200 is that it also has 8 bits of available I/O that I will use for some simple handshaking. The remaining section of the programmer are address latches.
Since the Z80 is RAM based, there is nothing in memory on power-up so the programmer will always be connected. When the combo is powered up, the PIC immediately puts the Z80 in reset while it configures the bus control circuits to be in-active. The MCP2200 can also be configured to power up with its I/O in a given state. The MODE pin is programmed to power up low and this pin is monitored by the PIC. When MODE is low, the PIC releases the Z80 from reset. It also continues to monitor MODE and the Reset button. If the user presses the reset button, the PIC de-bounces the press and sends a  clean reset signal to the Z80. It will do this indefinitely.

When the PC wants to program the RAM chip, MODE is set high. The PIC will detect this as a request to go into command mode and acknowledge the PC by setting the ACK line high. The Z80 will continue to run as normal.  The PC will issue a Get Bus command and the PIC will assert, BUSRQ, wait for BUSACK, then enable the address latches and switch the control line MUX. The PC will then issue a Set Address command to have the PIC set the address latches to the starting address of where the program is to be loaded. The PC will then start sending 128 byte packets to the PIC containing the programmed data and a checksum byte for error detection. Once all the data is programmed, the PIC will release the programmer bus and control, release BUSRQ, wait for BUSACK to release, then reset the Z80.


The entire 64K address space can be programmed in under 7 seconds.


The programmer.

The programmer and Z80 "married"

No comments:

Post a Comment