Stage 2 Hardware, Non-volatile RAM

A project log for Building a 22MHz Z80 Computer in 4 Stages

Step-by-step instruction on building a high-performance, CP/M-ready, expandable Z80 computer

plasmodePlasmode 02/28/2019 at 17:120 Comments

While loading a small bootstrap code serially is fairly easy and quick, but as the application software get bigger and numerous, the process of loading several software every power cycle or reset become tedious.  Fortunately the RAM has extremely low power consumption in standby voltage of 3V or less, so its content can be retained for a year or more with a button cell battery and non volatile memory controller.  In stage 2 of the hardware assembly, we'll add the button cell battery and install the non-volatile memory controller.

The two jumpers in U6 are removed and replaced with DS1210.  A CR1220 3V Lithium cell is inserted in the battery holder as shown.  While it is not absolutely required, the voltage supervisor is also installed in this stage so we don't have to press reset button for every power cycle.

Just because the RAM's content is retained between power cycles, we are not yet safe from having to load code over and over again.  This is because application codes like CP/M takes over the entire memory space and write into page 0 (0x0 to 0xFF) of the RAM.  To prevent the bootstrap code from being overwritten, we need to place it in a banked memory that's accessible at reset, but can be switched out and replaced with another bank.  As explained in the Theory of Operation, the 128KB RAM is splitted into four 32KB banks with bank 2 as the common memory always at the top 32KB and bank 3 located at lower 32KB at reset.  A bank select register can place bank 0 or bank 1 at lower 32KB under software control.  Z80Monitor has a command 'c0' that copies itself from 0xB000-0xBFFF into 0x0-0xFFF of bank 3 and switches out bank 3 and switch in bank 0 in its place.  So with the 'c0' command, Z80Mon make itself boot-able and hidden from other applications.  Other applications such as CP/M will have unfetter access to the entire Z80 memory space, but power cycle or reset will enable the bank 3 where Z80Mon is located and boot up with Z80Mon.

We can zero out the entire memory (other than ZMon) with the 'z' command, but it will still boot up with reset or power cycling.  With bootstrap code safely protected from application software, we can now move the jumper to RAM bootstrap position and power up to Z80Monitor every power cycle or reset.

Bank 3 has 32KB of storage, but only 4K is reserved for Z80Mon.  The remaining space can be used to store other application, such as SCMonitor.  This is what 'c1' command does.  It copies whatever program from 0x0 to 0x3FFF to bank 3 and 'b1' command restore the content of 0x0-0x3FFF from bank 3 and start execution from 0x0.  So 'c1' command saves SCMonitor, and 'b1' command boot up SCMonitor.  Bank 3 is effectively a non-volatile memory, but one that can be easily written.

With the serial bootstrap capability and banked nonvolatile RAM, we now have a Z80 computer that can be reprogrammed from scratch at will, but yet retain its characteristics over reset and power cycling.  We are ready for stage 3 and tackle CP/M!