Close
0%
0%

Z80-MBC2: a 4 ICs homebrew Z80 computer

Homemade 8MHz Z80 SBC, 128kB banked RAM, RTC, SD (HD emulation), Basic and Forth interpreter, CP/M 2.2 and 3, UCSD Pascal, Fuzix and more...

Similar projects worth following
The Z80-MBC2 is an easy to build Z80 SBC (Single Board Computer).It is the "evolution" of the Z80-MBC (https://hackaday.io/project/19000), with a SD as "disk emulator" and with a 128KB banked RAM for CP/M 3 (but it can run CP/M 2.2, QP/M 2.71, UCSD Pascal, Collapse OS and Fuzix too).

It has an optional on board 16x GPIO expander, and uses common cheap add-on modules for the SD and the RTC options. It has an "Arduino heart" using an Atmega32A as EEPROM and "universal" I/O emulator (so a "legacy" EPROM programmer is not needed).

It is a complete development "ecosystem", and using the iLoad boot mode it is possible cross-compile, load and execute on the target an Assembler or C program (using the SDCC compiler) with a single command (like in the Arduino IDE).

* NOTE TO THE READER *: Due to a text size limitation of the Hackaday. io site a few chapters have been moved to "Log files". In this case you have just to click on the link of the chapter's title to open a new tab and read it.





* * HARDWARE OVERVIEW * *

The needed ICs for the "base system" are:

  • Z80 CPU CMOS (Z84C00) 8Mhz or greater
  • Atmega32A
  • TC551001-70 (128kB RAM)
  • 74HC00

If you want the 16x GPIO expansion (GPE option) add a MCP23017 too.

The schematic and the BOM are attached in the Files section. The MCU Atmega32A is used as universal I/O subsystem, as Eeprom, and as reset and 4/8MHz clock generator for the Z80 CPU.
Inside the Atmega32A it is flashed an Arduino bootloader taken from here, and it is possible to use the Board Manager of the Arduino IDE to "import" it.

Flash the Arduino bootloader at first (with the method you prefer), next you can upload the IOS "sketch" (the I/O Subsystem that interacts with the Z80 bus and "virtualizes" the EEPROM and all the peripherals seen by the Z80 CPU) using Arduino IDE.

You can use the on board ICSP port J3 (also called ISP port) to write the bootloader, but remember to disconnect any other connector when using it. Also both SD and RTC modules (if present) must be removed from the board when the ICSP port is in use.

As clock source for the Z80 CPU it is used the 16MHz Atmega32A oscillator, so the "external 16MHZ osc." bootloader variant must be chosen when flashing the bootloader from the Arduino IDE!.

The 74HC00 is used as RS flipflop to stop the Z80 CPU during I/O operation, giving the needed time to the Atmega32A to interact with the Z80 bus, and as part of the MMU.

Note that only the CMOS version of the Z80 CPU can be used here. This because only CMOS version, under given condition that are respected in this schematic, has logical levels compatibles with Atmega32A and 74HC00.


NOTES ABOUT THE COMPONENTS

You should use a  Z80 CMOS speed grade of at least 8MHz for full speed, but setting the clock speed at 4MHz you can use a 4MHz Z80 CMOS version too (or you can try to overclock it at 8MHz...). The 74HC00 can be substituted with a 74HCT00 if you already have one. The RAM chip TC551001-70 can be substituted with any suitable 128kB SRAM).

Please note that the USER led  * must * be blue or white (or pink... I've some pink leds that seems to have a Vf like blue one. May be I'll do a board with them...) just to be sure that V(forward) is >= 2.7V (otherwise the USER key may not work as expected).

The J4 connector (AUX_P) is used as auxiliary power connector when an add-on board (uCom or uTerm) is connected.

The three solder jumpers (SJ1-3) on the bottom side are not currently supported and must  be left opened (as stated in the schematic).


THE GPE OPTION (GPIO CONNECTOR)

It is possible to choose to populate on the PCB a GPIO port expander (U5) to add 16 bidirectional GPIO pins. The GPE option (see the schematic) can be used with the SPP Adapter board (see the paragraph: SPP (STANDARD PARALLEL PORT) ADAPTER BOARD).

The pinout of the GPIO (J7) connector is:


THE SERIAL PORT

The  SERIAL port (J2, see schematic) can be connected with a TTL-RS232 adapter, or with a serial-USB adapter.
I've used a serial-USB adapter that acts also as power source for the Z80-MBC, and has the DTR signal for the "autoreset" driven from the Arduino IDE. For a terminal that has a serial TTL port no adapter is needed.

Of course to upload a "sketch" from Arduino IDE you need to use a serial-USB adapter connected to the SERIAL port.

Note that the RTS and CTS pins of the SERIAL port are not currently supported and must be left not connected (as the NC pin!).

The 3V3 pin of the serial-USB adapter must be left disconnected  (if present).

You should use those Serial-USB adapters that have the DTR pin on the connector. It is suggested to have also the CTS/RTS signals available for future upgrades.

Please note that all the pin...

Read more »

Z80-MBC2 User Manual - D081023-R280424.pdf

Z80-MBC2 User Manual

Adobe Portable Document Format - 11.66 MB - 04/28/2024 at 15:52

Preview

SD-S220718-R290823-v2.zip

The content of the microSD needed to run CP/M 2.2, CP/M 3.0, QP/M 2.71, UCSD Pascal, Collapse OS and Fuzix with IOS S220718-R290823 (More info in the Changelog.txt file inside)

Zip Archive - 5.81 MB - 10/06/2023 at 10:40

Download

S220718-R290823_IOS-Z80-MBC2.zip

The sketch for the IOS (with the needed libraries). Unzip into a folder and open the .ino file (with Arduino IDE). IOS must be uploaded into the Atmega32A flash. Adds support for Fuzix OS and the SPP Adapter board (more info in the changelog inside the .ino file).

Zip Archive - 43.75 kB - 09/24/2023 at 11:59

Download

S220718-R290823_IOS-Z80-MBC2.ino.with_bootloader_atmega32_16000000L.hex

The sketch for the IOS in executable format (.HEX) with the bootloader. This executable file is intended for use with a programmer as the Atmel Ice or AVRISPmkII or others (Fuse bits: High Byte 0xD6, Low Byte 0xAF, Lock Byte 0xCF)

x-hex - 59.90 kB - 09/24/2023 at 12:04

Download

SPP Adapter board - A240721-R270921.zip

All the documentation needed to build the SSP (Standard Parallel Port) Adapter board (A240721-R270921) including schematic, PCB assembling guide, Gerber files for PCB production. PCB is 55mm x 60mm 2-layers.

Zip Archive - 747.10 kB - 09/24/2023 at 15:10

Download

View all 13 files

  • 1 × See the file "A040618 BOM v2.ods" in the FILES section.

  • * * ​USING THE TASM CROSS ASSEMBLER * *

    Just4Fun10/09/2023 at 14:07 0 comments

    * * USING THE TASM CROSS ASSEMBLER * *

    The TASM cross assembler (Windows CLI application) can be used for various CPU. It can be downloaded from here. The on-line manual is here.

    Using the TASM cross assembler it is possible setup a toolchain to program the Z80-MBC2, doing all the development on a PC and uploading the code with the serial port and then executing it on the target Z80-MBC2 with iLoad.

    After the download of the TASM zip file, unzip it into your working directory (it is the folder where your assembler source files are stored) and to assemble an user source give the command:

    tasm -s -h -c -g0 -80  <Your_source.asm> out.hex

    It will be created the out.hex file (Intel-hex formatted executable file).

    Now you can upload and execute out.hex using the iLoad boot mode of the Z80-MBC2.

    Remember that iLoad will take the first address of the Intel-Hex stream as the starting address of the program, and after the loading will jump to it.

    At this point you can follow the same steps to create an automated toolchain described in the paragraph "SDCC: SETTING UP AN AUTOMATED TOOLCHAIN (WINDOWS)".


    TASM: USING AUTOBOOT

    If you want create a binary file to use with the Autoboot boot mode you can generate it with the command:

    tasm -s -h -c -g3 -80   <Your_source.asm> out.bin

    It will be created a flat binary file out.bin. Then rename out.bin as autoboot.bin and copy it into the root of the SD used by the Z80-MBC2.

  • * * ​USING THE SDCC CROSS COMPILER * *

    Just4Fun10/05/2023 at 13:27 0 comments

    * * USING THE SDCC CROSS COMPILER * *

    Using the SDCC (Small Device C Compiler) cross-compiler it is possible setup a toolchain to program the Z80-MBC2 with the C language, doing all the development on a PC and uploading the code with the serial port and then executing it on the target Z80-MBC2 with iLoad

    SDCC can be found here: https://sdcc.sourceforge.net/.

    After installing it, SDCC needs to be in some way instructed about how to deal with the specific HW of the Z80-MBC2.

    For this reason in the SD image, inside the \SDCC folder, there are two support files: S190818-R011023_crt0.s and S290923_Z80-MBC2.c.

    All the steps needed to configure the toolchain are explained below (we will assume a Windows operating system here, but the steps are similar for Linux):


    STEP 1:

    Copy the two support files S190818-R011023_crt0.s and S290923_Z80-MBC2.c from the SD image (\SDCC folder) to your working directory (it is the folder where your C source files are stored) and compile the first file with the command (from your working directory):

    sdasz80 -plosgff -o S190818-R011023_crt0.s

    It will be created the S190818-R011023_crt0.rel file.


    STEP 2:

    Now it's time to compile the second support file (S290923_Z80-MBC2.c). Here things are a little more complex because this file can be compiled in two different ways which differ depending on whether interrupts are enabled or not.

    The  need to have interrupts enabled or not depends on whether your user program uses them or not.

    To enable the interrupts support compile with the command (from your working directory):

    sdcc -c -mz80 -DZ80MBC2IRQ S290923_Z80-MBC2.c

    Instead to disable the interrupts support compile with (from your working directory):

    sdcc -c -mz80 S290923_Z80-MBC2.c

    It will be created the S290923_Z80-MBC2.rel file.


    STEP 3:

    iLoad uses the first address as starting address for the execution, so the executable file (Intel-Hex formatted) must be in ascending address order. This is not guaranteed by SDCC, so you need to use the srec_cat utility to sort the file. You can download this utility from here: https://srecord.sourceforge.net/  and then you have to copy the srec_cat.exe file into your working directory.


    All done!

    To compile your source file the command is (from your working directory):

    sdcc -mz80 --no-std-crt0 S190818-R011023_crt0.rel <your_source.c> S290923_Z80-MBC2.rel -o temp.hex

    It will be created the temp.hex file (Intel-hex formatted executable file).

    Now to sort the file give the command (from your working directory):

    srec_cat -disable-sequence-warnings temp.hex -Intel -o out.hex -Intel

    This will create the sorted file ready to be loaded with iLoad: out.hex.

    Now you can upload and execute out.hex using the iLoad boot mode of the Z80-MBC2.


    SDCC: SETTING UP AN AUTOMATED TOOLCHAIN (WINDOWS)

    To create an automated toolchain you need another "ingredient", a terminal emulator supporting scripts. Here we will use Tera Term. You can download Tera Term from here: https://ttssh2.osdn.jp/index.html.en.

    After installing Tera Term, from the SD image inside the \SDCC folder, copy into the working directory the following batch files: SDC.BAT and L.BAT.

    Before using the L.BAT batch file you have to adapt two parameters according with the configuration of your PC. 

    Go at line 18 and verify the path where Tera Term (ttermpro.exe) is installed, and at line 19 the number of the COM port used to connect the Z80-MBC2 to your PC.

    You need also to copy the Tera Term script LoadZ80.ttl from the /SDCC folder (inside the SD image) to the directory where Tera Term (ttermpro.exe) is installed, and adapt the parameter at line 15 with the complete path of your working directory in your system.

    Now to compile your_source.c file give the command (from your working directory):

    SDC your_source.c

    and to upload and execute it on the Z80-MBC2 (from your working directory):

    L

    Remember to close the Tera Term window...

    Read more »

View all 2 project logs

Enjoy this project?

Share

Discussions

Robin Hourahane wrote 01/05/2021 at 16:57 point

Hi, I've been working on my own version of IOS-MBC2 but I think I'm running out of memory trying to use the Arduino SD library so I can new files to the SD card. Has anyone manage to use this library or another to write new files to the SD card.

Alternatively has anyone tried using a ATmega128 instead of the ATmega32, can't see why it wouldn't work but thought I'd ask before trying just in case its a known to cause issues.

Thanks.

  Are you sure? yes | no

villaromba wrote 01/11/2021 at 16:17 point

I currently use the Atmel 1284 if of any help for extra mem.

https://github.com/HomebrewMicros/Z80-MBC2-ATMEL1284

  Are you sure? yes | no

Robin Hourahane wrote 01/11/2021 at 18:35 point

Thanks for the info.

Hoping that the extra memory will allow me to use the standard SD library to read, write and create files so I can add opcodes to access the FAT file system from CP/M using a new program to do the copying.

My SD changes are on the  use-std-sd-library branch https://github.com/rhourahane/IOS-Z80-MBC2

Update:

I have now got a Atmega1284 and its working well thanks to villaomba timer changes. My SD card problems were down to the change in library not memory but as I want to add a lot more functionality I'll stick with the larger chip.

  Are you sure? yes | no

Robin Hourahane wrote 01/05/2021 at 16:51 point

Hi, Does anyone know the status of the Fuzix port that was mentioned a while back.

  Are you sure? yes | no

Arthur wrote 11/21/2020 at 07:19 point

Hi guys, i have a problem with my mbc2. After the boot menu is displayed i choose basic or something else, nothing is starting. Only this message appears:

IOS: Loading boot program... Done
IOS: Z80 is running from now

I have no SD Card installed. Can someone help me? Thank you

  Are you sure? yes | no

coopzone-dc wrote 12/05/2020 at 14:19 point

You need the SD card to boot anything, they are all files on it.

  Are you sure? yes | no

Arthur wrote 12/05/2020 at 20:18 point

Hey coopzone, thanks for your reply. I've already add the sd card modul with the extracted files from the zip to my setup and i flashed the atmega with S220718-R280819_IOS version. Still same problem. I think the SRAM could be the problem, but unfortunately i haven't a second one to swap.

  Are you sure? yes | no

coopzone-dc wrote 12/06/2020 at 09:06 point

Arthur, i can't seem to reply to your post below. But if you suspect the SRAM, you can get a know working one quickly on https://www.ebay.co.uk/itm/264964185618

But i would check out the 7400 and surrounding logic first, The diodes can be a bit tricky as well.

  Are you sure? yes | no

DarS wrote 12/09/2020 at 21:21 point

Arthur, please remember that MBC2 can have two firmwares: IOS and IOS-Lite. The second one (the Lite) offers just Basic and Forth, and does NOT require SD card for work. So you can flash the Lite to ATmega to check the bare bones, including SRAM. It might be faulty, but I guess it is rare.

I haven't check the ATmega code, but I guess the ATmega would indicate some error if/when SRAM is defective (ROM image is loaded to TC551001 RAM by the Atmega32A during the system boot, and only then the control is passed to Z80). You haven't seen any error from ATmega, so I guess your SRAM is good.

If you want to get more details, you can download my brief guide: https://github.com/DarS007/Z80-MBC2_guide/blob/master/Z80-MBC2-DarS007-20200927.pdf  I guess it might be useful.

  Are you sure? yes | no

Arthur wrote 12/11/2020 at 18:06 point

Problem solved. I've soldered RN1 and RN2 in wrong alignment.

Now it works :)

  Are you sure? yes | no

DarS wrote 09/28/2020 at 20:29 point

Thanks for a plenty of joy with Z80-MBC2 !  I just assembled my copy and spent few evenings trying to understand the details. A kind of a user guide was crafted with all the information I could gather from different sources. If you find it useful, feel free to use/share:

https://github.com/DarS007/Z80-MBC2_guide

  Are you sure? yes | no

ermanno wrote 09/04/2020 at 18:08 point

To format the sd card I have to use fat or fat32 and what size of the allocation unit?

Or it doesn't matter.

  Are you sure? yes | no

Just4Fun wrote 09/05/2020 at 08:42 point

You can use both FAT or FAT32. The micro-SD can be a legacy one (max 2 GB if I remember well) or a SDHC. Nothing more. No others special setting are needed.

  Are you sure? yes | no

Vinicius Monteiro wrote 08/19/2020 at 00:13 point

Hey so i'm kinda noob in those stuffs (besides having a technical degree in eletronics, I never really had time to mess around with them in my spare time) and I have like a very, very limited knowledge in Arduino. How can I import a bootloader to the ATMega? Thanks everyone, and mainly for the chap who post the project.

  Are you sure? yes | no

Peter Tabatt wrote 08/04/2020 at 15:51 point

Hello,

an other day an other question. I use the hex-file S220718-R280819_IOS-Z80-MBC2... on the Atmega 32 and after starting the Z80-MBC2 i got the boot-menu. So far so good! I explored the menu-entries and after choosing Forth, I run into Forth on every reboot. How can I get back to the boot-menu at startup?

  Are you sure? yes | no

villaromba wrote 08/04/2020 at 16:38 point

Easiest way is to press both RESET & USER keys, release the RESET key holding the USER key down until the IOS led starts to blink, or you see the menu on the screen.

  Are you sure? yes | no

Peter Tabatt wrote 07/30/2020 at 17:11 point

What a cool project! It's like time-travelling for me, I feel backsituated to my time as student. My first homecomputer had a Z80-clone but no CP/M. Z80-MBC2 is a very cool project! I assembled two and they are up and running.

Now I have one question: How can I put some programs into the disk-images on the sd-card?

Is there a tool to fill the disk-images on a PC? Under Windows?

  Are you sure? yes | no

villaromba wrote 07/31/2020 at 21:45 point

If you scroll down on the 'Logs' menu you'll find  CPMtools GUI and instructions. on how to use it. (You can of course use XMODEM  to transfer files over to disk directly.)

  Are you sure? yes | no

Jonathan Guthrie wrote 07/29/2020 at 16:30 point

Thank you for this most excellent project!

I built this recently.  It works fine for me, and now I'm trying to figure out what I want to do with it.

  Are you sure? yes | no

Sigmar Roßmann wrote 07/13/2020 at 12:04 point

Hello

I am trying to compile the S220718-R260119_IOS-Z80-MBC2.ino in the Arduino studio.
If I uploaded the HEX file with the Atmel studio on the Z80-MBC2, everything works.
But the serial interface does not print any characters.

Does somebody has any idea.

Excuse my English.

greeting

Sigmar

  Are you sure? yes | no

Sigmar Roßmann wrote 07/13/2020 at 12:32 point

Hello
already solved

I had to change the HardwareSerial.cpp in one place.

  Are you sure? yes | no

Sigmar Roßmann wrote 07/06/2020 at 16:34 point

Hello everybody,


can someone explain to me what in the Arduino * ino
the 

"void serialEvent ()
// Set INT_ to ACTIVE if there are received chars from serial to read and if the interrupt generation is enabled
{ if ((Serial.available ()) && Z80IntEnFlag) digitalWrite (INT_, LOW);
} "

Interupt on Z80 is triggered?

greeting

Sigmar

  Are you sure? yes | no

Just4Fun wrote 07/07/2020 at 13:43 point

As explained in the comment it triggers the INT line when a char is ready to be read by the Z80 CPU and the INT trigger flag is enabled in the IOS firmware.

This mode is used only by the stand-alone ROM Basic.

(Not sure to have understood the question...)

  Are you sure? yes | no

Sigmar Roßmann wrote 07/11/2020 at 16:14 point

Thanks that was exactly the right answer.

  Are you sure? yes | no

ermanno wrote 06/15/2020 at 20:12 point

just4fun you're right I confused it with the pinout of the bc 557 which is inverted.

  Are you sure? yes | no

ermanno wrote 06/15/2020 at 17:20 point

The transistors 2n2907 if inserted as in the serigraphy would have the collector connected to vcc, instead it is the emitter that must be connected to vcc, therefore the flat part of the transistor goes towards the Z80 and not towards the LEDs. However inserted in one way or another they work equally. How should these transistors be inserted ...

  Are you sure? yes | no

Just4Fun wrote 06/15/2020 at 17:38 point

  Are you sure? yes | no

Stephan Kraus wrote 04/12/2020 at 20:57 point

Hi!

Thanks for the great project!

I am wondering if there is the chance to add a second serial port to hook up a printer or paper tape reader?

Best regards

Stephan

  Are you sure? yes | no

Sebastiano Grimaldi wrote 03/29/2020 at 17:51 point

I've just checked the SD card board with an Arduino uno board. I've correctly write and read file in the SD. I understand that the SD card board is working! Thanks a lot to give me some idea for additional debug. 

  Are you sure? yes | no

Just4Fun wrote 03/29/2020 at 18:38 point

If you press and release the RESET key, D11 must do a single very fast blink (also if the SD module is not present) just before the IOS SD error is "printed" on the serial port. If you don't see it there must be an assembling error/fault.

  Are you sure? yes | no

Sebastiano Grimaldi wrote 03/31/2020 at 18:17 point

Thanks for the suggestion, I've fixed the problem. Now my MBC2 is perfectly running! Best regards, Sebastiano 

  Are you sure? yes | no

Sebastiano Grimaldi wrote 03/29/2020 at 13:43 point

Very compliment for this fantastic project!

I build MBC2 everything it's working fine except the SD card!

Using the lite IOS I run BASIC and FORTRAN then the system is working.

Loading on the ATMEGA32 the IOS with SD management I got the following error:

Z80-MBC2 - A040618
IOS - I/O Subsystem - S220718-R280819

IOS: Z80 clock set at 8MHz
IOS: Found RTC DS3231 Module (29/03/20 15:34:36)
IOS: RTC DS3231 temperature sensor: 19C
IOS: CP/M Autoexec is OFF

IOS: Select boot mode or system parameters:

 0: No change (3)
 1: Basic
 2: Forth
 3: Load OS from Disk Set 1
 4: Autoboot
 5: iLoad
 6: Change Z80 clock speed (->4MHz)
 7: Toggle CP/M Autoexec (->ON)
 8: Change Disk Set 1
 9: Change RTC time/date

Enter your choice >1  Ok

IOS: SD error 2 (NOT_READY on MOUNT operation)
IOS: Check SD and press a key to repeat

There is not any activity on the LED D11, I've cheched all the route trace, no error.

Any help, please?


  Are you sure? yes | no

Just4Fun wrote 03/29/2020 at 14:21 point

That error says that there isn't any SD card inserted into the SD module...

BTW: Are you sure to have inserted the SD card module correctly (as shown in the photos)?

  Are you sure? yes | no

Sebastiano Grimaldi wrote 03/29/2020 at 17:05 point

Thanks for fast response! The sd card is correctly installed with the proper contents as per your zip archive. Best regards, Sebastiano

  Are you sure? yes | no

m.uhlmann.zwickau wrote 06/10/2020 at 06:18 point

I have also this error some times. After reconnect the sd-card or the board it works.

  Are you sure? yes | no

mikeh32217 wrote 03/25/2020 at 07:02 point

Awesome project, great fun and perfect for the era of the shutin!

Thanks for the effort!

  Are you sure? yes | no

[deleted]

[this comment has been deleted]

[deleted]

[this comment has been deleted]

Edgar Salgado wrote 06/09/2020 at 19:32 point

Hello! Any chance you are willing to sell me a spare PCB? :)

  Are you sure? yes | no

O.E wrote 02/16/2020 at 17:47 point

Hi,

After i setud circuit i connected to computer using FTDI programmer leds blinking correctly but terminal is not  open in computer when  pressing buttons.

  Are you sure? yes | no

Just4Fun wrote 02/17/2020 at 11:18 point

Hi,

have you set the sw terminal at 115200 8N1 (No HW handshaking)...? Are you sure to have connected RX/TX correctly...? An other "source" of common problems is a wrong fuse setting when flashing the bootloader first time...

  Are you sure? yes | no

wojtek.p wrote 01/13/2020 at 12:20 point

Hi,

Does anyone have 3D models (step format) for Z80-MBC2, uCom and UTerm? I want to design a 3D printing case and it would be helpful. If anyone has, please send to wojtek.p@onet.pl

Thanks

Wojtek

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates